提交 78aefb52 编写于 作者: P Peter Krempa

qemu: monitor: Remove qemuMonitorGetBlockExtent

Now that qemuMonitorGetAllBlockStatsInfo collects also wr_highest_offset
the whole function can be killed.
上级 15fa84ac
......@@ -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,
......
......@@ -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);
......
......@@ -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,
......
......@@ -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);
......
......@@ -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,
......
......@@ -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);
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册