]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Fix regressions BlockStats/Info APIs in QEMU driver
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 2 Jun 2011 13:55:56 +0000 (14:55 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 3 Jun 2011 13:55:11 +0000 (14:55 +0100)
The change 18c2a592064d69499f70428e498f4a3cb5161cda caused
some regressions in behaviour of virDomainBlockStats
and virDomainBlockInfo in the QEMU driver.

The virDomainBlockInfo API stopped working for inactive
guests if querying a block device.

The virDomainBlockStats API did not promptly report
an error if the guest was not running in some cases.

* src/qemu/qemu_driver.c: Fix inactive guest handling
  in BlockStats/Info APIs

src/qemu/qemu_driver.c

index 5632d62956b3e47e56060e3520be58ce33a20245..ec23bb346e9b3e8ecc267006cc3ffbe50c44663f 100644 (file)
@@ -5531,6 +5531,12 @@ qemudDomainBlockStats (virDomainPtr dom,
         goto cleanup;
     }
 
+    if (!virDomainObjIsActive(vm)) {
+        qemuReportError(VIR_ERR_OPERATION_INVALID,
+                        "%s", _("domain is not running"));
+        goto cleanup;
+    }
+
     for (i = 0 ; i < vm->def->ndisks ; i++) {
         if (STREQ(path, vm->def->disks[i]->dst)) {
             disk = vm->def->disks[i];
@@ -5994,7 +6000,8 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom,
        highest allocated extent from QEMU */
     if (disk->type == VIR_DOMAIN_DISK_TYPE_BLOCK &&
         format != VIR_STORAGE_FILE_RAW &&
-        S_ISBLK(sb.st_mode)) {
+        S_ISBLK(sb.st_mode) &&
+        virDomainObjIsActive(vm)) {
         qemuDomainObjPrivatePtr priv = vm->privateData;
 
         if ((priv->jobActive == QEMU_JOB_MIGRATION_OUT)
@@ -6017,19 +6024,16 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom,
             if (qemuDomainObjBeginJob(vm) < 0)
                 goto cleanup;
 
-            if (!virDomainObjIsActive(vm)) {
-                qemuReportError(VIR_ERR_OPERATION_INVALID,
-                                "%s", _("domain is not running"));
-                goto endjob;
+            if (virDomainObjIsActive(vm)) {
+                qemuDomainObjEnterMonitor(vm);
+                ret = qemuMonitorGetBlockExtent(priv->mon,
+                                                disk->info.alias,
+                                                &info->allocation);
+                qemuDomainObjExitMonitor(vm);
+            } else {
+                ret = 0;
             }
 
-            qemuDomainObjEnterMonitor(vm);
-            ret = qemuMonitorGetBlockExtent(priv->mon,
-                                            disk->info.alias,
-                                            &info->allocation);
-            qemuDomainObjExitMonitor(vm);
-
-endjob:
             if (qemuDomainObjEndJob(vm) == 0)
                 vm = NULL;
         }