Re: [libvirt] [PATCHv3 31/36] qemu: monitor: Add support for backing name specification for block-stream

2014-06-02 Thread Eric Blake
On 05/30/2014 02:37 AM, Peter Krempa wrote:
 To allow changing the name that is recorded in the top of the current
 image chain used in a block pull/rebase operation, we need to specify
 the backing name to qemu. This is done via the backing-file attribute
 to the block-stream commad.

s/commad/command/

 ---
  src/qemu/qemu_driver.c   |  8 
  src/qemu/qemu_migration.c|  6 +++---
  src/qemu/qemu_monitor.c  | 12 +++-
  src/qemu/qemu_monitor.h  |  3 ++-
  src/qemu/qemu_monitor_json.c | 15 +++
  src/qemu/qemu_monitor_json.h |  1 +
  6 files changed, 32 insertions(+), 13 deletions(-)
 

Again, I think the qemu_capability.[ch] change is needed as a separate
commit; but you can get away with the same capability for both
block-commit and block-pull since both commands are learning the feature
in the same qemu series.  Not sure if the capability needs to come
first, or if you have it later in the series.

This patch is okay (although this and 30/36 should probably wait until
Jeff's series is actually committed into qemu.git).


 @@ -3759,6 +3759,7 @@ int
  qemuMonitorJSONBlockJob(qemuMonitorPtr mon,

 +
 +if (backingName  mode != BLOCK_JOB_PULL) {
 +virReportError(VIR_ERR_INTERNAL_ERROR, %s,
 +   _(backing name is supported only for block pull));
 +return -1;
 +}

[side note - I honestly don't know why we tried to cram so much into
qemuMonitorJSONBlockJob through the entire stack; it might have been
simpler to have one qemu_monitor.h entry point per QMP command, rather
than trying to multiplex.  But it may not be worth the refactor now]

If these were separate functions instead of multiplexed through a mode
argument, then you wouldn't need a check like this (since the check will
never fail unless we introduce a bug in qemu_driver.c).

ACK

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCHv3 31/36] qemu: monitor: Add support for backing name specification for block-stream

2014-05-30 Thread Peter Krempa
To allow changing the name that is recorded in the top of the current
image chain used in a block pull/rebase operation, we need to specify
the backing name to qemu. This is done via the backing-file attribute
to the block-stream commad.
---
 src/qemu/qemu_driver.c   |  8 
 src/qemu/qemu_migration.c|  6 +++---
 src/qemu/qemu_monitor.c  | 12 +++-
 src/qemu/qemu_monitor.h  |  3 ++-
 src/qemu/qemu_monitor_json.c | 15 +++
 src/qemu/qemu_monitor_json.h |  1 +
 6 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0619156..72e92cc 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -14834,7 +14834,7 @@ qemuDomainBlockPivot(virConnectPtr conn,
 /* Probe the status, if needed.  */
 if (!disk-mirroring) {
 qemuDomainObjEnterMonitor(driver, vm);
-rc = qemuMonitorBlockJob(priv-mon, device, NULL, 0, info,
+rc = qemuMonitorBlockJob(priv-mon, device, NULL, NULL, 0, info,
   BLOCK_JOB_INFO, true);
 qemuDomainObjExitMonitor(driver, vm);
 if (rc  0)
@@ -15051,7 +15051,7 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
 qemuDomainObjEnterMonitor(driver, vm);
 ret = qemuMonitorBlockJob(priv-mon, device,
   baseIndex ? baseSource-path : base,
-  bandwidth, info, mode, async);
+  NULL, bandwidth, info, mode, async);
 qemuDomainObjExitMonitor(driver, vm);
 if (ret  0)
 goto endjob;
@@ -15091,8 +15091,8 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
 virDomainBlockJobInfo dummy;

 qemuDomainObjEnterMonitor(driver, vm);
-ret = qemuMonitorBlockJob(priv-mon, device, NULL, 0, dummy,
-  BLOCK_JOB_INFO, async);
+ret = qemuMonitorBlockJob(priv-mon, device, NULL, NULL, 0,
+  dummy, BLOCK_JOB_INFO, async);
 qemuDomainObjExitMonitor(driver, vm);

 if (ret = 0)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 5754f73..327679d 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1308,7 +1308,7 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
_(canceled by client));
 goto error;
 }
-mon_ret = qemuMonitorBlockJob(priv-mon, diskAlias, NULL, 0,
+mon_ret = qemuMonitorBlockJob(priv-mon, diskAlias, NULL, NULL, 0,
   info, BLOCK_JOB_INFO, true);
 qemuDomainObjExitMonitor(driver, vm);

@@ -1360,7 +1360,7 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
 continue;
 if (qemuDomainObjEnterMonitorAsync(driver, vm,
QEMU_ASYNC_JOB_MIGRATION_OUT) == 0) 
{
-if (qemuMonitorBlockJob(priv-mon, diskAlias, NULL, 0,
+if (qemuMonitorBlockJob(priv-mon, diskAlias, NULL, NULL, 0,
 NULL, BLOCK_JOB_ABORT, true)  0) {
 VIR_WARN(Unable to cancel block-job on '%s', diskAlias);
 }
@@ -1426,7 +1426,7 @@ qemuMigrationCancelDriveMirror(qemuMigrationCookiePtr mig,
QEMU_ASYNC_JOB_MIGRATION_OUT)  0)
 goto cleanup;

-if (qemuMonitorBlockJob(priv-mon, diskAlias, NULL, 0,
+if (qemuMonitorBlockJob(priv-mon, diskAlias, NULL, NULL, 0,
 NULL, BLOCK_JOB_ABORT, true)  0)
 VIR_WARN(Unable to stop block job on %s, diskAlias);
 qemuDomainObjExitMonitor(driver, vm);
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 590081c..df5dc3a 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3354,6 +3354,7 @@ int qemuMonitorScreendump(qemuMonitorPtr mon,
 int qemuMonitorBlockJob(qemuMonitorPtr mon,
 const char *device,
 const char *base,
+const char *backingName,
 unsigned long bandwidth,
 virDomainBlockJobInfoPtr info,
 qemuMonitorBlockJobCmd mode,
@@ -3362,9 +3363,10 @@ int qemuMonitorBlockJob(qemuMonitorPtr mon,
 int ret = -1;
 unsigned long long speed;

-VIR_DEBUG(mon=%p, device=%s, base=%s, bandwidth=%luM, info=%p, mode=%o, 
-  modern=%d, mon, device, NULLSTR(base), bandwidth, info, mode,
-  modern);
+VIR_DEBUG(mon=%p, device=%s, base=%s, backingName=%s, bandwidth=%luM, 
+  info=%p, mode=%o, modern=%d,
+  mon, device, NULLSTR(base), NULLSTR(backingName),
+  bandwidth, info, mode, modern);

 /* Convert bandwidth MiB to bytes - unfortunately the JSON QMP protocol is
  * limited to LLONG_MAX also for