Revert "block: Remove deprecated -drive option serial"
authorCornelia Huck <cohuck@redhat.com>
Fri, 6 Jul 2018 13:06:18 +0000 (15:06 +0200)
committerKevin Wolf <kwolf@redhat.com>
Tue, 10 Jul 2018 12:36:11 +0000 (14:36 +0200)
This reverts commit b0083267444a5e0f28391f6c2831a539f878d424.

Hold off removing this for one more QEMU release (current libvirt
release still uses it.)

Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 files changed:
block/block-backend.c
blockdev.c
hw/block/block.c
hw/block/nvme.c
hw/block/virtio-blk.c
hw/ide/qdev.c
hw/scsi/scsi-disk.c
hw/usb/dev-storage.c
include/hw/block/block.h
include/sysemu/blockdev.h
qemu-doc.texi
qemu-options.hx
tests/ahci-test.c
tests/ide-test.c

index ac8c3e0b1c062e512018f2497f57566942e8c42a..e94e3d592930d3c990bcff3623a1b5ae17e8ae05 100644 (file)
@@ -419,6 +419,7 @@ static void drive_info_del(DriveInfo *dinfo)
         return;
     }
     qemu_opts_del(dinfo->opts);
+    g_free(dinfo->serial);
     g_free(dinfo);
 }
 
index 37eb40670b7a9c5803e28dd11822861ad7b5ad4a..6c530769fdfff9b419a5c671d405c508fe09b8aa 100644 (file)
@@ -730,6 +730,10 @@ QemuOptsList qemu_legacy_drive_opts = {
             .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,
@@ -772,10 +776,12 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
     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 */
@@ -943,6 +949,9 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
         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;
@@ -1017,6 +1026,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
     dinfo->type = type;
     dinfo->bus = bus_id;
     dinfo->unit = unit_id;
+    dinfo->serial = g_strdup(serial);
 
     blk_set_legacy_dinfo(blk, dinfo);
 
index cf0eb826f168fbc6e4a8f66883428c394c3267f9..b6c80ab0b7756945382286d71082f610b329ff82 100644 (file)
 #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;
index fc7dacb816c8cb61c075d2537b0618e0b0c6d9d1..5e508ab1b32667aa3d9e66575ef5db0bfb768a63 100644 (file)
@@ -1217,6 +1217,7 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp)
         return;
     }
 
+    blkconf_serial(&n->conf, &n->serial);
     if (!n->serial) {
         error_setg(errp, "serial property not set");
         return;
index 225fe44b7a1b38746bdcbd79f6b1b9602a1fd265..50b5c869e300e3233c276fc2c0499de1fc7dde40 100644 (file)
@@ -935,6 +935,7 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
         return;
     }
 
+    blkconf_serial(&conf->conf, &conf->serial);
     if (!blkconf_apply_backend_options(&conf->conf,
                                        blk_is_read_only(conf->conf.blk), true,
                                        errp)) {
index 573b022e1e0e6777f4cec55ec1a8599170c75fb8..f395d245927501f848a1b022896ebb5720c9ecc3 100644 (file)
@@ -188,6 +188,7 @@ static void ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind, Error **errp)
         return;
     }
 
+    blkconf_serial(&dev->conf, &dev->serial);
     if (kind != IDE_CD) {
         if (!blkconf_geometry(&dev->conf, &dev->chs_trans, 65535, 16, 255,
                               errp)) {
index 32f3f96ff870b6ec0ca1a7c48e7e09ffff5e8887..d7df3570297bf6f7d98bbbc01657d14470e5529d 100644 (file)
@@ -2378,6 +2378,7 @@ static void scsi_realize(SCSIDevice *dev, Error **errp)
         return;
     }
 
+    blkconf_serial(&s->qdev.conf, &s->serial);
     blkconf_blocksizes(&s->qdev.conf);
 
     if (s->qdev.conf.logical_block_size >
index cd5551d94f350a0aa78fcdd5018828cf521cefce..45a9487cdb77d1aa19e1c2e827a34f30da1b0936 100644 (file)
@@ -599,6 +599,7 @@ static void usb_msd_storage_realize(USBDevice *dev, Error **errp)
         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)) {
index e9f9e2223f3400accf94e1a97b92c91ba523a734..d4f4dfffab91d3f593a1f9821b72b77b4b20252b 100644 (file)
@@ -72,6 +72,7 @@ static inline unsigned int get_physical_block_exp(BlockConf *conf)
 
 /* 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);
index 24954b94e08eb1b6eb86fa053ebafa9054801a61..c0ae3700ec4120bc9cb887072c1d02fdf929390b 100644 (file)
@@ -35,6 +35,7 @@ struct DriveInfo {
     bool is_default;            /* Added by default_drive() ?  */
     int media_cd;
     QemuOpts *opts;
+    char *serial;
     QTAILQ_ENTRY(DriveInfo) next;
 };
 
index d3924e928e361e7f603f665f46fe5033b401f444..d343affd6d1a712992aa87313e9b58064ec85012 100644 (file)
@@ -2887,6 +2887,11 @@ with ``-device ...,netdev=x''), or ``-nic user,smb=/some/dir''
 (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
index 16208f63f291256a8c6903543b78e4af6240e3ea..381648b9cb459a1ea135099ecddcca57e5dbfc5f 100644 (file)
@@ -805,7 +805,7 @@ ETEXI
 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"
@@ -879,6 +879,10 @@ The default mode is @option{cache=writeback}.
 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),
index 937ed2f91091a5f8ad2652ffbe52afafba45fcae..1a7b761304b6546e4952b703f2afe690ab21f8ba 100644 (file)
@@ -180,12 +180,12 @@ static AHCIQState *ahci_boot(const char *cli, ...)
         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;
index f39431b1a90ee5e437160c39547565e86185a450..2384c2c3e2c2c68942f8f86b0fa11b12d2de0d8d 100644 (file)
@@ -529,8 +529,8 @@ static void test_bmdma_no_busmaster(void)
 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");
 }
@@ -561,8 +561,8 @@ static void test_identify(void)
     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);