Commit bb44619b authored by Kevin Wolf's avatar Kevin Wolf Committed by Stefan Hajnoczi

blockdev: Keep a copy of DriveInfo.serial

Pointing to a QemuOpts element is surprising and can lead to subtle
use-after-free errors when the QemuOpts is freed after all options are
Signed-off-by: default avatarKevin Wolf <>
Signed-off-by: default avatarStefan Hajnoczi <>
parent 376609cc
......@@ -191,6 +191,7 @@ static void drive_uninit(DriveInfo *dinfo)
QTAILQ_REMOVE(&drives, dinfo, next);
......@@ -566,7 +567,9 @@ DriveInfo *drive_init(QemuOpts *opts, BlockInterfaceType block_default_type)
dinfo->trans = translation;
dinfo->opts = opts;
dinfo->refcount = 1;
dinfo->serial = serial;
if (serial != NULL) {
dinfo->serial = g_strdup(serial);
QTAILQ_INSERT_TAIL(&drives, dinfo, next);
bdrv_set_on_error(dinfo->bdrv, on_read_error, on_write_error);
......@@ -40,7 +40,7 @@ struct DriveInfo {
int media_cd;
int cyls, heads, secs, trans;
QemuOpts *opts;
const char *serial;
char *serial;
QTAILQ_ENTRY(DriveInfo) next;
int refcount;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment