Re: [PATCH 4/4] qemu: Use disk wwn in qemu command line

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 18, 2012 at 10:47:12AM +0800, Osier Yang wrote:
> All of ide-drive, ide-hd, ide-cd, scsi-disk, scsi-hd, and scsi-cd
> supports wwn property. (NB, scsi-block doesn't support to set wwn).
> 
> * src/qemu/qemu_command.c: Error out if underlying QEMU doesn't
> support wwn property for the device; Set wwn for the device otherwise.
> 
> * tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args: New test
> * tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.xml: Likewise
> * tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.args: Likewise
> * tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.xml: Likewise
> * tests/qemuxml2argvtest.c: Add the new tests.
> ---
>  src/qemu/qemu_command.c                            |   33 ++++++++++++++++++
>  .../qemuxml2argv-disk-ide-wwn.args                 |    6 +++
>  .../qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.xml |   28 ++++++++++++++++
>  .../qemuxml2argv-disk-scsi-disk-wwn.args           |   10 ++++++
>  .../qemuxml2argv-disk-scsi-disk-wwn.xml            |   35 ++++++++++++++++++++
>  tests/qemuxml2argvtest.c                           |    7 ++++
>  6 files changed, 119 insertions(+), 0 deletions(-)
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.xml
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.args
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.xml
> 
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 06a4bac..7511ad3 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -2453,6 +2453,15 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
>          goto error;
>      }
>  
> +    if (disk->wwn) {
> +        if ((disk->bus != VIR_DOMAIN_DISK_BUS_IDE) &&
> +            (disk->bus != VIR_DOMAIN_DISK_BUS_SCSI)) {
> +            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                           _("Only ide and scsi disk support wwn"));
> +            goto error;
> +        }
> +    }
> +
>      if (disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) {
>          /* make sure that both the bus and the qemu binary support
>           *  type='lun' (SG_IO).
> @@ -2475,6 +2484,11 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
>                             _("disk device='lun' is not supported by this QEMU"));
>              goto error;
>          }
> +        if (disk->wwn) {
> +            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                           _("Setting wwn is not supported for lun device"));
> +            goto error;
> +        }
>      }
>  
>      switch (disk->bus) {
> @@ -2485,6 +2499,14 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
>              goto error;
>          }
>  
> +        if (disk->wwn &&
> +            !qemuCapsGet(qemuCaps, QEMU_CAPS_IDE_DRIVE_WWN)) {
> +            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                           _("Setting wwn for ide disk is not supported "
> +                             "by this QEMU"));
> +            goto error;
> +        }
> +
>          if (qemuCapsGet(caps, QEMU_CAPS_IDE_CD)) {
>              if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
>                  virBufferAddLit(&opt, "ide-cd");
> @@ -2508,6 +2530,14 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
>              }
>          }
>  
> +        if (disk->wwn &&
> +            !qemuCapsGet(qemuCaps, QEMU_CAPS_SCSI_DISK_WWN)) {
> +            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                           _("Setting wwn for scsi disk is not supported "
> +                             "by this QEMU"));
> +            goto error;
> +        }
> +
>          controllerModel =
>              virDomainDiskFindControllerModel(def, disk,
>                                               VIR_DOMAIN_CONTROLLER_TYPE_SCSI);
> @@ -2647,6 +2677,9 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
>                                disk->blockio.physical_block_size);
>      }
>  
> +    if (disk->wwn)
> +        virBufferAsprintf(&opt, ",wwn=%s", disk->wwn);
> +
>      if (virBufferError(&opt)) {
>          virReportOOMError();
>          goto error;
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args
> new file mode 100644
> index 0000000..4b8a543
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args
> @@ -0,0 +1,6 @@
> +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
> +/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefaults \
> +-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \
> +-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-ide0-0-1,serial=WD-WMAP9A966149 \
> +-device ide-hd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1,wwn=5000c50015ea71ad \
> +-usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.xml
> new file mode 100644
> index 0000000..dccec95
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.xml
> @@ -0,0 +1,28 @@
> +<domain type='qemu'>
> +  <name>QEMUGuest1</name>
> +  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
> +  <memory unit='KiB'>219136</memory>
> +  <currentMemory unit='KiB'>219136</currentMemory>
> +  <vcpu placement='static'>1</vcpu>
> +  <os>
> +    <type arch='i686' machine='pc'>hvm</type>
> +    <boot dev='hd'/>
> +  </os>
> +  <clock offset='utc'/>
> +  <on_poweroff>destroy</on_poweroff>
> +  <on_reboot>restart</on_reboot>
> +  <on_crash>destroy</on_crash>
> +  <devices>
> +    <emulator>/usr/bin/qemu</emulator>
> +    <disk type='block' device='disk'>
> +      <source dev='/dev/HostVG/QEMUGuest1'/>
> +      <target dev='hda' bus='ide'/>
> +      <serial>WD-WMAP9A966149</serial>
> +      <wwn>5000c50015ea71ad</wwn>
> +      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
> +    </disk>
> +    <controller type='usb' index='0'/>
> +    <controller type='ide' index='0'/>
> +    <memballoon model='virtio'/>
> +  </devices>
> +</domain>
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.args
> new file mode 100644
> index 0000000..fe4591b
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.args
> @@ -0,0 +1,10 @@
> +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
> +/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults \
> +-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \
> +-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 \
> +-device lsi,id=scsi1,bus=pci.0,addr=0x4 \
> +-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-scsi0-0-1-0 \
> +-device scsi-cd,bus=scsi0.0,channel=0,scsi-id=1,lun=0,drive=drive-scsi0-0-1-0,id=scsi0-0-1-0,wwn=5000c50015ea71ac \
> +-drive file=/dev/HostVG/QEMUGuest2,if=none,id=drive-scsi0-0-0-0 \
> +-device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,wwn=5000c50015ea71ad \
> +-usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.xml
> new file mode 100644
> index 0000000..dc35548
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-wwn.xml
> @@ -0,0 +1,35 @@
> +<domain type='qemu'>
> +  <name>QEMUGuest1</name>
> +  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
> +  <memory unit='KiB'>219136</memory>
> +  <currentMemory unit='KiB'>219136</currentMemory>
> +  <vcpu placement='static'>1</vcpu>
> +  <os>
> +    <type arch='i686' machine='pc'>hvm</type>
> +    <boot dev='hd'/>
> +  </os>
> +  <clock offset='utc'/>
> +  <on_poweroff>destroy</on_poweroff>
> +  <on_reboot>restart</on_reboot>
> +  <on_crash>destroy</on_crash>
> +  <devices>
> +    <emulator>/usr/bin/qemu</emulator>
> +    <disk type='block' device='cdrom'>
> +      <source dev='/dev/HostVG/QEMUGuest1'/>
> +      <target dev='sda' bus='scsi'/>
> +      <address type='drive' controller='0' bus='0' target='1' unit='0'/>
> +      <serial>WD-WMAP9A966149</serial>
> +      <wwn>5000c50015ea71ac</wwn>
> +    </disk>
> +    <disk type='block' device='disk'>
> +      <source dev='/dev/HostVG/QEMUGuest2'/>
> +      <target dev='sdb' bus='scsi'/>
> +      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
> +      <wwn>5000c50015ea71ad</wwn>
> +    </disk>
> +    <controller type='usb' index='0'/>
> +    <controller type='scsi' index='0' model='virtio-scsi'/>
> +    <controller type='scsi' index='1' model='lsilogic'/>
> +    <memballoon model='virtio'/>
> +  </devices>
> +</domain>
> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
> index 4daa68d..0ec3c2c 100644
> --- a/tests/qemuxml2argvtest.c
> +++ b/tests/qemuxml2argvtest.c
> @@ -471,6 +471,10 @@ mymain(void)
>      DO_TEST("disk-scsi-disk-split",
>              QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
>              QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI_PCI);
> +    DO_TEST("disk-scsi-disk-wwn",
> +            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
> +            QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI_PCI,
> +            QEMU_CAPS_SCSI_DISK_WWN);
>      DO_TEST("disk-scsi-vscsi",
>              QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
>      DO_TEST("disk-scsi-virtio-scsi",
> @@ -802,6 +806,9 @@ mymain(void)
>      DO_TEST("disk-ide-drive-split",
>              QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
>              QEMU_CAPS_IDE_CD);
> +    DO_TEST("disk-ide-wwn",
> +            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_IDE_CD,
> +            QEMU_CAPS_DRIVE_SERIAL, QEMU_CAPS_IDE_DRIVE_WWN);
>  
>      DO_TEST("disk-geometry", QEMU_CAPS_DRIVE);
>      DO_TEST("disk-blockio",

  ACK, please push !

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]