[PATCH] qemu: Drop has_ccw_address from _qemuAgentDiskAddress

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

 



In recent patches new mambers to _qemuAgentDiskAddress struct
were introduced to keep optional CCW address sent by the guest
agent. These two members are a struct to store CCW address into
and a boolean to keep track whether the CCW address is valid.
Well, we can hold the same information with a pointer - instead
of storing the CCW address structure let's keep just a pointer to
it.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_agent.c  | 18 ++++++++++++------
 src/qemu/qemu_agent.h  |  3 +--
 src/qemu/qemu_driver.c |  9 +++------
 3 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index b155896e78..af0397e6e2 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -1824,6 +1824,7 @@ qemuAgentDiskAddressFree(qemuAgentDiskAddressPtr info)
     g_free(info->serial);
     g_free(info->bus_type);
     g_free(info->devnode);
+    g_free(info->ccw_addr);
     g_free(info);
 }
 
@@ -1899,12 +1900,17 @@ qemuAgentGetDiskAddress(virJSONValuePtr json)
     GET_DISK_ADDR(pci, &addr->pci_controller.function, "function");
 
     if ((ccw = virJSONValueObjectGet(json, "ccw-address"))) {
-        addr->has_ccw_address = true;
-        GET_DISK_ADDR(ccw, &addr->ccw_addr.cssid, "cssid");
-        if (addr->ccw_addr.cssid == 0)  /* Guest CSSID 0 is 0xfe on host */
-            addr->ccw_addr.cssid = 0xfe;
-        GET_DISK_ADDR(ccw, &addr->ccw_addr.ssid, "ssid");
-        GET_DISK_ADDR(ccw, &addr->ccw_addr.devno, "devno");
+        g_autofree virDomainDeviceCCWAddressPtr ccw_addr = NULL;
+
+        ccw_addr = g_new0(virDomainDeviceCCWAddress, 1);
+
+        GET_DISK_ADDR(ccw, &ccw_addr->cssid, "cssid");
+        if (ccw_addr->cssid == 0)  /* Guest CSSID 0 is 0xfe on host */
+            ccw_addr->cssid = 0xfe;
+        GET_DISK_ADDR(ccw, &ccw_addr->ssid, "ssid");
+        GET_DISK_ADDR(ccw, &ccw_addr->devno, "devno");
+
+        addr->ccw_addr = g_steal_pointer(&ccw_addr);
     }
 #undef GET_DISK_ADDR
 
diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h
index 4ea9b9dc1e..0d47230161 100644
--- a/src/qemu/qemu_agent.h
+++ b/src/qemu/qemu_agent.h
@@ -77,8 +77,7 @@ struct _qemuAgentDiskAddress {
     unsigned int target;
     unsigned int unit;
     char *devnode;
-    bool has_ccw_address;
-    virDomainDeviceCCWAddress ccw_addr;
+    virDomainDeviceCCWAddressPtr ccw_addr;
 };
 void qemuAgentDiskAddressFree(qemuAgentDiskAddressPtr addr);
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuAgentDiskAddress, qemuAgentDiskAddressFree);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 62b0852c33..a376824854 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -18887,8 +18887,7 @@ qemuAgentFSInfoToPublic(qemuAgentFSInfoPtr agent,
 
         diskDef = virDomainDiskByAddress(vmdef,
                                          &agentdisk->pci_controller,
-                                         agentdisk->has_ccw_address ?
-                                             &agentdisk->ccw_addr : NULL,
+                                         agentdisk->ccw_addr,
                                          agentdisk->bus,
                                          agentdisk->target,
                                          agentdisk->unit);
@@ -19931,8 +19930,7 @@ qemuAgentDiskInfoFormatParams(qemuAgentDiskInfoPtr *info,
             /* match the disk to the target in the vm definition */
             diskdef = virDomainDiskByAddress(vmdef,
                                              &info[i]->address->pci_controller,
-                                             info[i]->address->has_ccw_address ?
-                                                &info[i]->address->ccw_addr : NULL,
+                                             info[i]->address->ccw_addr,
                                              info[i]->address->bus,
                                              info[i]->address->target,
                                              info[i]->address->unit);
@@ -20017,8 +20015,7 @@ qemuAgentFSInfoFormatParams(qemuAgentFSInfoPtr *fsinfo,
             /* match the disk to the target in the vm definition */
             diskdef = virDomainDiskByAddress(vmdef,
                                              &d->pci_controller,
-                                             d->has_ccw_address ?
-                                                 &d->ccw_addr : NULL,
+                                             d->ccw_addr,
                                              d->bus,
                                              d->target,
                                              d->unit);
-- 
2.26.2




[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]

  Powered by Linux