[PATCH 5/5] qemu: monitor: Remove qemuMonitorGetBlockExtent

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

 



Now that qemuMonitorGetAllBlockStatsInfo collects also wr_highest_offset
the whole function can be killed.
---
 src/qemu/qemu_monitor.c      |  16 -----
 src/qemu/qemu_monitor.h      |   3 -
 src/qemu/qemu_monitor_json.c | 138 -------------------------------------------
 src/qemu/qemu_monitor_json.h |   3 -
 src/qemu/qemu_monitor_text.c |  10 ----
 src/qemu/qemu_monitor_text.h |   3 -
 tests/qemumonitorjsontest.c  |  34 -----------
 7 files changed, 207 deletions(-)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 904d682..93fcc7f 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1829,22 +1829,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,
                        unsigned long long size)
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index b4d6538..483496c 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -392,9 +392,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);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index b2ce33f..d496a32 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -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,
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index c0ee4ce..b76d85b 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -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);
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 1b6bc02..2e77534 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -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,
diff --git a/src/qemu/qemu_monitor_text.h b/src/qemu/qemu_monitor_text.h
index 6f9a215..3fa603b 100644
--- a/src/qemu/qemu_monitor_text.h
+++ b/src/qemu/qemu_monitor_text.h
@@ -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);
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 6246737..6df91b3 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -1438,7 +1438,6 @@ testQemuMonitorJSONqemuMonitorJSONGetBlockStatsInfo(const void *data)
     virHashTablePtr blockstats = NULL;
     qemuBlockStatsPtr stats;
     int ret = -1;
-    unsigned long long extent;

     const char *reply =
         "{"
@@ -1585,39 +1584,6 @@ testQemuMonitorJSONqemuMonitorJSONGetBlockStatsInfo(const void *data)
     CHECK("virtio-disk1", 85, 348160, 8232156, 0, 0, 0, 0, 0, 0ULL)
     CHECK("ide0-1-0", 16, 49250, 1004952, 0, 0, 0, 0, 0, 0ULL)

-    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
-- 
2.4.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



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