return;
}
qemu_opts_del(dinfo->opts);
+ g_free(dinfo->serial);
g_free(dinfo);
}
.name = "if",
.type = QEMU_OPT_STRING,
.help = "interface (ide, scsi, sd, mtd, floppy, pflash, virtio)",
+ },{
+ .name = "serial",
+ .type = QEMU_OPT_STRING,
+ .help = "disk serial number",
},{
.name = "file",
.type = QEMU_OPT_STRING,
const char *werror, *rerror;
bool read_only = false;
bool copy_on_read;
+ const char *serial;
const char *filename;
Error *local_err = NULL;
int i;
const char *deprecated[] = {
+ "serial"
};
/* Change legacy command line options into QMP ones */
goto fail;
}
+ /* Serial number */
+ serial = qemu_opt_get(legacy_opts, "serial");
+
/* no id supplied -> create one */
if (qemu_opts_id(all_opts) == NULL) {
char *new_id;
dinfo->type = type;
dinfo->bus = bus_id;
dinfo->unit = unit_id;
+ dinfo->serial = g_strdup(serial);
blk_set_legacy_dinfo(blk, dinfo);
#include "qapi/qapi-types-block.h"
#include "qemu/error-report.h"
+void blkconf_serial(BlockConf *conf, char **serial)
+{
+ DriveInfo *dinfo;
+
+ if (!*serial) {
+ /* try to fall back to value set with legacy -drive serial=... */
+ dinfo = blk_legacy_dinfo(conf->blk);
+ if (dinfo) {
+ *serial = g_strdup(dinfo->serial);
+ }
+ }
+}
+
void blkconf_blocksizes(BlockConf *conf)
{
BlockBackend *blk = conf->blk;
return;
}
+ blkconf_serial(&n->conf, &n->serial);
if (!n->serial) {
error_setg(errp, "serial property not set");
return;
return;
}
+ blkconf_serial(&conf->conf, &conf->serial);
if (!blkconf_apply_backend_options(&conf->conf,
blk_is_read_only(conf->conf.blk), true,
errp)) {
return;
}
+ blkconf_serial(&dev->conf, &dev->serial);
if (kind != IDE_CD) {
if (!blkconf_geometry(&dev->conf, &dev->chs_trans, 65535, 16, 255,
errp)) {
return;
}
+ blkconf_serial(&s->qdev.conf, &s->serial);
blkconf_blocksizes(&s->qdev.conf);
if (s->qdev.conf.logical_block_size >
return;
}
+ blkconf_serial(&s->conf, &dev->serial);
blkconf_blocksizes(&s->conf);
if (!blkconf_apply_backend_options(&s->conf, blk_is_read_only(blk), true,
errp)) {
/* Configuration helpers */
+void blkconf_serial(BlockConf *conf, char **serial);
bool blkconf_geometry(BlockConf *conf, int *trans,
unsigned cyls_max, unsigned heads_max, unsigned secs_max,
Error **errp);
bool is_default; /* Added by default_drive() ? */
int media_cd;
QemuOpts *opts;
+ char *serial;
QTAILQ_ENTRY(DriveInfo) next;
};
(for embedded NICs). The new syntax allows different settings to be
provided per NIC.
+@subsection -drive serial=... (since 2.10.0)
+
+The drive serial argument is replaced by the the serial argument
+that can be specified with the ``-device'' parameter.
+
@subsection -usbdevice (since 2.10.0)
The ``-usbdevice DEV'' argument is now a synonym for setting
DEF("drive", HAS_ARG, QEMU_OPTION_drive,
"-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i]\n"
" [,cache=writethrough|writeback|none|directsync|unsafe][,format=f]\n"
- " [,snapshot=on|off][,rerror=ignore|stop|report]\n"
+ " [,snapshot=on|off][,serial=s][,rerror=ignore|stop|report]\n"
" [,werror=ignore|stop|report|enospc][,id=name][,aio=threads|native]\n"
" [,readonly=on|off][,copy-on-read=on|off]\n"
" [,discard=ignore|unmap][,detect-zeroes=on|off|unmap]\n"
Specify which disk @var{format} will be used rather than detecting
the format. Can be used to specify format=raw to avoid interpreting
an untrusted format header.
+@item serial=@var{serial}
+This option specifies the serial number to assign to the device. This
+parameter is deprecated, use the corresponding parameter of @code{-device}
+instead.
@item werror=@var{action},rerror=@var{action}
Specify which @var{action} to take on write and read errors. Valid actions are:
"ignore" (ignore the error and try to continue), "stop" (pause QEMU),
s = ahci_vboot(cli, ap);
va_end(ap);
} else {
- cli = "-drive if=none,id=drive0,file=%s,cache=writeback,format=%s"
+ cli = "-drive if=none,id=drive0,file=%s,cache=writeback,serial=%s"
+ ",format=%s"
" -M q35 "
"-device ide-hd,drive=drive0 "
- "-global ide-hd.serial=%s "
"-global ide-hd.ver=%s";
- s = ahci_boot(cli, tmp_path, imgfmt, "testdisk", "version");
+ s = ahci_boot(cli, tmp_path, "testdisk", imgfmt, "version");
}
return s;
static void test_bmdma_setup(void)
{
ide_test_start(
- "-drive file=%s,if=ide,cache=writeback,format=raw "
- "-global ide-hd.serial=%s -global ide-hd.ver=%s",
+ "-drive file=%s,if=ide,serial=%s,cache=writeback,format=raw "
+ "-global ide-hd.ver=%s",
tmp_path, "testdisk", "version");
qtest_irq_intercept_in(global_qtest, "ioapic");
}
int ret;
ide_test_start(
- "-drive file=%s,if=ide,cache=writeback,format=raw "
- "-global ide-hd.serial=%s -global ide-hd.ver=%s",
+ "-drive file=%s,if=ide,serial=%s,cache=writeback,format=raw "
+ "-global ide-hd.ver=%s",
tmp_path, "testdisk", "version");
dev = get_pci_device(&bmdma_bar, &ide_bar);