]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: monitor: Remove qemuMonitorGetBlockExtent
authorPeter Krempa <pkrempa@redhat.com>
Tue, 23 Jun 2015 12:43:00 +0000 (14:43 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 26 Jun 2015 14:41:24 +0000 (16:41 +0200)
Now that qemuMonitorGetAllBlockStatsInfo collects also wr_highest_offset
the whole function can be killed.

src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c
src/qemu/qemu_monitor_json.h
src/qemu/qemu_monitor_text.c
src/qemu/qemu_monitor_text.h
tests/qemumonitorjsontest.c

index 904d6825e3a9577de14ea853fa0cc30f6ba5a159..93fcc7fde1462a1aa9a5e34070ad5715e49e15cd 100644 (file)
@@ -1828,22 +1828,6 @@ qemuMonitorBlockStatsUpdateCapacity(qemuMonitorPtr mon,
 }
 
 
-int
-qemuMonitorGetBlockExtent(qemuMonitorPtr mon,
-                          const char *dev_name,
-                          unsigned long long *extent)
-{
-    VIR_DEBUG("dev_name=%s", dev_name);
-
-    QEMU_CHECK_MONITOR(mon);
-
-    if (mon->json)
-        return qemuMonitorJSONGetBlockExtent(mon, dev_name, extent);
-    else
-        return qemuMonitorTextGetBlockExtent(mon, dev_name, extent);
-}
-
-
 int
 qemuMonitorBlockResize(qemuMonitorPtr mon,
                        const char *device,
index d61fcf2e0ae25e6597e868efc2863f4a97e80420..ec1724f21fde593fd6e3b39eba6436655c1d92bb 100644 (file)
@@ -395,9 +395,6 @@ int qemuMonitorBlockStatsUpdateCapacity(qemuMonitorPtr mon,
                                         bool backingChain)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
 
-int qemuMonitorGetBlockExtent(qemuMonitorPtr mon,
-                              const char *dev_name,
-                              unsigned long long *extent);
 int qemuMonitorBlockResize(qemuMonitorPtr mon,
                            const char *dev_name,
                            unsigned long long size);
index d144f293b4d3a1871c7deb8d8a0460b15d6b5281..d3e98d4b01b1200362cc2bc24f122bff4a2723b3 100644 (file)
@@ -1660,36 +1660,6 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitorPtr mon,
 }
 
 
-typedef enum {
-    QEMU_MONITOR_BLOCK_EXTENT_ERROR_OK,
-    QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOPARENT,
-    QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOSTATS,
-    QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOOFFSET,
-} qemuMonitorBlockExtentError;
-
-
-static int
-qemuMonitorJSONDevGetBlockExtent(virJSONValuePtr dev,
-                                 unsigned long long *extent)
-{
-    virJSONValuePtr stats;
-    virJSONValuePtr parent;
-
-    if ((parent = virJSONValueObjectGetObject(dev, "parent")) == NULL)
-        return QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOPARENT;
-
-    if ((stats = virJSONValueObjectGetObject(parent, "stats")) == NULL)
-        return QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOSTATS;
-
-    if (virJSONValueObjectGetNumberUlong(stats, "wr_highest_offset",
-                                         extent) < 0) {
-        return QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOOFFSET;
-    }
-
-    return QEMU_MONITOR_BLOCK_EXTENT_ERROR_OK;
-}
-
-
 static int
 qemuMonitorJSONGetOneBlockStatsInfo(virJSONValuePtr dev,
                                     const char *dev_name,
@@ -1943,114 +1913,6 @@ qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitorPtr mon,
 }
 
 
-static int
-qemuMonitorJSONReportBlockExtentError(qemuMonitorBlockExtentError error)
-{
-    switch (error) {
-    case QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOPARENT:
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("blockstats parent entry was not in "
-                         "expected format"));
-        break;
-
-    case QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOSTATS:
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("blockstats stats entry was not in "
-                         "expected format"));
-        break;
-
-    case QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOOFFSET:
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("cannot read %s statistic"),
-                         "wr_highest_offset");
-        break;
-
-    case QEMU_MONITOR_BLOCK_EXTENT_ERROR_OK:
-        return 0;
-    }
-
-    return -1;
-}
-
-
-int qemuMonitorJSONGetBlockExtent(qemuMonitorPtr mon,
-                                  const char *dev_name,
-                                  unsigned long long *extent)
-{
-    int ret = -1;
-    size_t i;
-    bool found = false;
-    virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("query-blockstats",
-                                                     NULL);
-    virJSONValuePtr reply = NULL;
-    virJSONValuePtr devices;
-
-    *extent = 0;
-
-    if (!cmd)
-        return -1;
-
-    ret = qemuMonitorJSONCommand(mon, cmd, &reply);
-
-    if (ret == 0)
-        ret = qemuMonitorJSONCheckError(cmd, reply);
-    if (ret < 0)
-        goto cleanup;
-    ret = -1;
-
-    if (!(devices = virJSONValueObjectGetArray(reply, "return"))) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("blockstats reply was missing device list"));
-        goto cleanup;
-    }
-
-    for (i = 0; i < virJSONValueArraySize(devices); i++) {
-        virJSONValuePtr dev = virJSONValueArrayGet(devices, i);
-        const char *thisdev;
-        int err;
-        if (!dev || dev->type != VIR_JSON_TYPE_OBJECT) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("blockstats device entry was not in expected format"));
-            goto cleanup;
-        }
-
-        if ((thisdev = virJSONValueObjectGetString(dev, "device")) == NULL) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("blockstats device entry was not in expected format"));
-            goto cleanup;
-        }
-
-        /* New QEMU has separate names for host & guest side of the disk
-         * and libvirt gives the host side a 'drive-' prefix. The passed
-         * in dev_name is the guest side though
-         */
-        if (STRPREFIX(thisdev, QEMU_DRIVE_HOST_PREFIX))
-            thisdev += strlen(QEMU_DRIVE_HOST_PREFIX);
-
-        if (STRNEQ(thisdev, dev_name))
-            continue;
-
-        found = true;
-        if ((err = qemuMonitorJSONDevGetBlockExtent(dev, extent)) !=
-             QEMU_MONITOR_BLOCK_EXTENT_ERROR_OK) {
-            qemuMonitorJSONReportBlockExtentError(err);
-            goto cleanup;
-        }
-    }
-
-    if (!found) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("cannot find statistics for device '%s'"), dev_name);
-        goto cleanup;
-    }
-    ret = 0;
-
- cleanup:
-    virJSONValueFree(cmd);
-    virJSONValueFree(reply);
-    return ret;
-}
-
 /* Return 0 on success, -1 on failure, or -2 if not supported.  Size
  * is in bytes.  */
 int qemuMonitorJSONBlockResize(qemuMonitorPtr mon,
index c0ee4ce8951897ecef87188093efb3a089a3ec05..b76d85b9b6218a894aee0f65fcb6363019393e87 100644 (file)
@@ -77,9 +77,6 @@ int qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorPtr mon,
 int qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitorPtr mon,
                                             virHashTablePtr stats,
                                             bool backingChain);
-int qemuMonitorJSONGetBlockExtent(qemuMonitorPtr mon,
-                                  const char *dev_name,
-                                  unsigned long long *extent);
 int qemuMonitorJSONBlockResize(qemuMonitorPtr mon,
                                const char *devce,
                                unsigned long long size);
index 1b6bc02d9f77cb49ba543dffa764d36132516012..2e77534b27d5a96fa168a7de04ff7cb65b5c46bb 100644 (file)
@@ -968,16 +968,6 @@ qemuMonitorTextGetAllBlockStatsInfo(qemuMonitorPtr mon,
     return ret;
 }
 
-
-int qemuMonitorTextGetBlockExtent(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
-                                  const char *dev_name ATTRIBUTE_UNUSED,
-                                  unsigned long long *extent ATTRIBUTE_UNUSED)
-{
-    virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                   _("unable to query block extent with this QEMU"));
-    return -1;
-}
-
 /* Return 0 on success, -1 on failure, or -2 if not supported.  Size
  * is in bytes. */
 int qemuMonitorTextBlockResize(qemuMonitorPtr mon,
index 6f9a215d0d55fd8cf03cc988ea48e8fdc8992669..3fa603bcd444c02a0ac614aa00409c3722423386 100644 (file)
@@ -63,9 +63,6 @@ int qemuMonitorTextGetBlockInfo(qemuMonitorPtr mon,
 
 int qemuMonitorTextGetAllBlockStatsInfo(qemuMonitorPtr mon,
                                         virHashTablePtr hash);
-int qemuMonitorTextGetBlockExtent(qemuMonitorPtr mon,
-                                  const char *dev_name,
-                                  unsigned long long *extent);
 int qemuMonitorTextBlockResize(qemuMonitorPtr mon,
                                const char *device,
                                unsigned long long size);
index e72083e518ce87de332e3e21f43c37a85dce5920..96e6175d9027037667fb1bdf264ee7934ab6bd55 100644 (file)
@@ -1438,7 +1438,6 @@ testQemuMonitorJSONqemuMonitorJSONGetBlockStatsInfo(const void *data)
     virHashTablePtr blockstats = NULL;
     qemuBlockStatsPtr stats;
     int ret = -1;
-    unsigned long long extent;
 
     const char *reply =
         "{"
@@ -1582,39 +1581,6 @@ testQemuMonitorJSONqemuMonitorJSONGetBlockStatsInfo(const void *data)
     CHECK("virtio-disk1", 85, 348160, 8232156, 0, 0, 0, 0, 0, 0ULL, true)
     CHECK("ide0-1-0", 16, 49250, 1004952, 0, 0, 0, 0, 0, 0ULL, true)
 
-    if (qemuMonitorJSONGetBlockExtent(qemuMonitorTestGetMonitor(test), "virtio-disk0",
-                                      &extent) < 0)
-        goto cleanup;
-
-    if (extent != 5256018944ULL) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       "Invalid extent: %llu, expected 5256018944",
-                       extent);
-        goto cleanup;
-    }
-
-    if (qemuMonitorJSONGetBlockExtent(qemuMonitorTestGetMonitor(test), "virtio-disk1",
-                                      &extent) < 0)
-        goto cleanup;
-
-    if (extent != 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       "Invalid extent: %llu, expected 0",
-                       extent);
-        goto cleanup;
-    }
-
-    if (qemuMonitorJSONGetBlockExtent(qemuMonitorTestGetMonitor(test), "ide0-1-0",
-                                      &extent) < 0)
-        goto cleanup;
-
-    if (extent != 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       "Invalid extent: %llu, expected 0",
-                       extent);
-        goto cleanup;
-    }
-
     ret = 0;
 
 #undef CHECK