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

[libvirt] [PATCH 06/14] Add a 'format' arg to qemuMonitorChangeMedia() since JSON will support it



The current QEMU disk media change does not support setting the
disk format. The new JSON monitor will support this, so add an
extra parameter to pass this info in

* src/qemu/qemu_driver.c: Pass in disk format when changing media
* src/qemu/qemu_monitor.h, src/qemu/qemu_monitor.c,
  src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h:
  Add a 'format' arg to qemuMonitorChangeMedia()
---
 src/qemu/qemu_driver.c       |    9 ++++++++-
 src/qemu/qemu_monitor.c      |    9 +++++----
 src/qemu/qemu_monitor.h      |    3 ++-
 src/qemu/qemu_monitor_text.c |    7 ++++---
 src/qemu/qemu_monitor_text.h |    3 ++-
 5 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 3befe3d..2907976 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4716,7 +4716,14 @@ static int qemudDomainChangeEjectableMedia(virConnectPtr conn,
     qemuDomainObjPrivatePtr priv = vm->privateData;
     qemuDomainObjEnterMonitorWithDriver(driver, vm);
     if (newdisk->src) {
-        ret = qemuMonitorChangeMedia(priv->mon, devname, newdisk->src);
+        const char *format = NULL;
+        if (newdisk->type != VIR_DOMAIN_DISK_TYPE_DIR) {
+            if (newdisk->driverType)
+                format = newdisk->driverType;
+            else if (origdisk->driverType)
+                format = origdisk->driverType;
+        }
+        ret = qemuMonitorChangeMedia(priv->mon, devname, newdisk->src, format);
     } else {
         ret = qemuMonitorEjectMedia(priv->mon, devname);
     }
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 21f8c4b..a6b445e 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -783,12 +783,13 @@ int qemuMonitorEjectMedia(qemuMonitorPtr mon,
 
 int qemuMonitorChangeMedia(qemuMonitorPtr mon,
                            const char *devname,
-                           const char *newmedia)
+                           const char *newmedia,
+                           const char *format)
 {
-    DEBUG("mon=%p, fd=%d devname=%s newmedia=%s",
-          mon, mon->fd, devname, newmedia);
+    DEBUG("mon=%p, fd=%d devname=%s newmedia=%s format=%s",
+          mon, mon->fd, devname, newmedia, format);
 
-    return qemuMonitorTextChangeMedia(mon, devname, newmedia);
+    return qemuMonitorTextChangeMedia(mon, devname, newmedia, format);
 }
 
 
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 88d3dd7..14198fb 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -136,7 +136,8 @@ int qemuMonitorEjectMedia(qemuMonitorPtr mon,
                           const char *devname);
 int qemuMonitorChangeMedia(qemuMonitorPtr mon,
                            const char *devname,
-                           const char *newmedia);
+                           const char *newmedia,
+                           const char *format);
 
 
 int qemuMonitorSaveVirtualMemory(qemuMonitorPtr mon,
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index db15573..0d5ad79 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -693,7 +693,8 @@ cleanup:
 
 int qemuMonitorTextChangeMedia(qemuMonitorPtr mon,
                                const char *devname,
-                               const char *newmedia)
+                               const char *newmedia,
+                               const char *format ATTRIBUTE_UNUSED)
 {
     char *cmd = NULL;
     char *reply = NULL;
@@ -1016,8 +1017,8 @@ cleanup:
 }
 
 int qemuMonitorTextMigrateToUnix(qemuMonitorPtr mon,
-                             int background,
-                             const char *unixfile)
+                                 int background,
+                                 const char *unixfile)
 {
     char *dest = NULL;
     int ret = -1;
diff --git a/src/qemu/qemu_monitor_text.h b/src/qemu/qemu_monitor_text.h
index 6bca07a..bc52ad2 100644
--- a/src/qemu/qemu_monitor_text.h
+++ b/src/qemu/qemu_monitor_text.h
@@ -62,7 +62,8 @@ int qemuMonitorTextEjectMedia(qemuMonitorPtr mon,
                               const char *devname);
 int qemuMonitorTextChangeMedia(qemuMonitorPtr mon,
                                const char *devname,
-                               const char *newmedia);
+                               const char *newmedia,
+                               const char *format);
 
 
 int qemuMonitorTextSaveVirtualMemory(qemuMonitorPtr mon,
-- 
1.6.5.2


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