[libvirt] [PATCH 4/9] qemu: command: Rename and export qemuDiskBusNeedsDeviceArg

Peter Krempa posted 9 patches 7 years, 7 months ago
[libvirt] [PATCH 4/9] qemu: command: Rename and export qemuDiskBusNeedsDeviceArg
Posted by Peter Krempa 7 years, 7 months ago
Change the semantics to exactly opposite and rename it to
qemuDiskBusNeedsDriveArg. This will be necessary as some devices can't
be used with -blockdev.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_command.c | 23 +++++++++++++----------
 src/qemu/qemu_command.h |  1 +
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index cea31e6a24..8f5303ed95 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1330,15 +1330,18 @@ qemuCheckFips(void)
 }


-/* Unfortunately it is not possible to use
-   -device for floppies, or SD
-   devices. Fortunately, those don't need
-   static PCI addresses, so we don't really
-   care that we can't use -device */
-static bool
-qemuDiskBusNeedsDeviceArg(int bus)
+/**
+ * qemuDiskBusNeedsDriveArg:
+ * @bus: disk bus
+ *
+ * Unfortunately it is not possible to use -device for SD devices.
+ * Fortunately, those don't need  static PCI addresses, so we can use -drive
+ * without -device.
+ */
+bool
+qemuDiskBusNeedsDriveArg(int bus)
 {
-    return bus != VIR_DOMAIN_DISK_BUS_SD;
+    return bus == VIR_DOMAIN_DISK_BUS_SD;
 }


@@ -1636,7 +1639,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
     if (qemuBuildDriveSourceStr(disk, qemuCaps, &opt) < 0)
         goto error;

-    if (qemuDiskBusNeedsDeviceArg(disk->bus)) {
+    if (!qemuDiskBusNeedsDriveArg(disk->bus)) {
         char *drivealias = qemuAliasDiskDriveFromDisk(disk);
         if (!drivealias)
             goto error;
@@ -2250,7 +2253,7 @@ qemuBuildDiskCommandLine(virCommandPtr cmd,

     qemuBlockStorageSourceAttachDataFree(data);

-    if (qemuDiskBusNeedsDeviceArg(disk->bus)) {
+    if (!qemuDiskBusNeedsDriveArg(disk->bus)) {
         if (disk->bus == VIR_DOMAIN_DISK_BUS_FDC) {
             if (qemuBuildFloppyCommandLineOptions(cmd, def, disk,
                                                   bootindex) < 0)
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 4f1b360130..4452c98e4b 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -99,6 +99,7 @@ char *qemuBuildNicDevStr(virDomainDefPtr def,
                          virQEMUCapsPtr qemuCaps);

 char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk);
+bool qemuDiskBusNeedsDriveArg(int bus);

 qemuBlockStorageSourceAttachDataPtr
 qemuBuildStorageSourceAttachPrepareDrive(virDomainDiskDefPtr disk,
-- 
2.16.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/9] qemu: command: Rename and export qemuDiskBusNeedsDeviceArg
Posted by Ján Tomko 7 years, 7 months ago
On Tue, Jul 10, 2018 at 10:44:44AM +0200, Peter Krempa wrote:
>Change the semantics to exactly opposite and rename it to
>qemuDiskBusNeedsDriveArg. This will be necessary as some devices can't
>be used with -blockdev.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/qemu/qemu_command.c | 23 +++++++++++++----------
> src/qemu/qemu_command.h |  1 +
> 2 files changed, 14 insertions(+), 10 deletions(-)
>
>diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
>index cea31e6a24..8f5303ed95 100644
>--- a/src/qemu/qemu_command.c
>+++ b/src/qemu/qemu_command.c
>@@ -1330,15 +1330,18 @@ qemuCheckFips(void)
> }
>
>
>-/* Unfortunately it is not possible to use
>-   -device for floppies, or SD
>-   devices. Fortunately, those don't need
>-   static PCI addresses, so we don't really
>-   care that we can't use -device */
>-static bool
>-qemuDiskBusNeedsDeviceArg(int bus)
>+/**
>+ * qemuDiskBusNeedsDriveArg:
>+ * @bus: disk bus
>+ *
>+ * Unfortunately it is not possible to use -device for SD devices.
>+ * Fortunately, those don't need  static PCI addresses, so we can use -drive

Double space betweeen 'need' and 'static'.

>+ * without -device.
>+ */
>+bool
>+qemuDiskBusNeedsDriveArg(int bus)
> {
>-    return bus != VIR_DOMAIN_DISK_BUS_SD;
>+    return bus == VIR_DOMAIN_DISK_BUS_SD;
> }
>
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

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