mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-29 17:33:09 +00:00
qemudDomainBlockStats use qemudDiskDeviceName
* src/qemu_driver.c: use qemudDiskDeviceName to determine the block device name in qemudDomainBlockStats(), patch by Guido Günther daniel
This commit is contained in:
parent
f009e2aae2
commit
8348610c5e
@ -1,3 +1,8 @@
|
|||||||
|
Fri Oct 17 11:25:43 CEST 2008 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
|
* src/qemu_driver.c: use qemudDiskDeviceName to determine the block
|
||||||
|
device name in qemudDomainBlockStats(), patch by Guido Günther
|
||||||
|
|
||||||
Fri Oct 17 11:20:48 CEST 2008 Daniel Veillard <veillard@redhat.com>
|
Fri Oct 17 11:20:48 CEST 2008 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
* src/qemu_driver.c: fix qemudDiskDeviceName to handle disk devices
|
* src/qemu_driver.c: fix qemudDiskDeviceName to handle disk devices
|
||||||
|
@ -2756,11 +2756,13 @@ qemudDomainBlockStats (virDomainPtr dom,
|
|||||||
{
|
{
|
||||||
struct qemud_driver *driver =
|
struct qemud_driver *driver =
|
||||||
(struct qemud_driver *)dom->conn->privateData;
|
(struct qemud_driver *)dom->conn->privateData;
|
||||||
char *dummy, *info;
|
char *dummy, *info = NULL;
|
||||||
const char *p, *eol;
|
const char *p, *eol;
|
||||||
char qemu_dev_name[32];
|
const char *qemu_dev_name = NULL;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
int i, ret = -1;
|
||||||
const virDomainObjPtr vm = virDomainFindByID(&driver->domains, dom->id);
|
const virDomainObjPtr vm = virDomainFindByID(&driver->domains, dom->id);
|
||||||
|
virDomainDiskDefPtr disk = NULL;
|
||||||
|
|
||||||
if (!vm) {
|
if (!vm) {
|
||||||
qemudReportError (dom->conn, dom, NULL, VIR_ERR_INVALID_DOMAIN,
|
qemudReportError (dom->conn, dom, NULL, VIR_ERR_INVALID_DOMAIN,
|
||||||
@ -2773,36 +2775,29 @@ qemudDomainBlockStats (virDomainPtr dom,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
for (i = 0 ; i < vm->def->ndisks ; i++) {
|
||||||
* QEMU internal block device names are different from the device
|
if (STREQ(path, vm->def->disks[i]->dst)) {
|
||||||
* names we use in libvirt, so we need to map between them:
|
disk = vm->def->disks[i];
|
||||||
*
|
break;
|
||||||
* hd[a-] to ide0-hd[0-]
|
}
|
||||||
* cdrom to ide1-cd0
|
}
|
||||||
* fd[a-] to floppy[0-]
|
|
||||||
*/
|
if (!disk) {
|
||||||
if (STRPREFIX (path, "hd") && c_islower(path[2]))
|
|
||||||
snprintf (qemu_dev_name, sizeof (qemu_dev_name),
|
|
||||||
"ide0-hd%d", path[2] - 'a');
|
|
||||||
else if (STREQ (path, "cdrom"))
|
|
||||||
strcpy (qemu_dev_name, "ide1-cd0");
|
|
||||||
else if (STRPREFIX (path, "fd") && c_islower(path[2]))
|
|
||||||
snprintf (qemu_dev_name, sizeof (qemu_dev_name),
|
|
||||||
"floppy%d", path[2] - 'a');
|
|
||||||
else {
|
|
||||||
qemudReportError (dom->conn, dom, NULL, VIR_ERR_INVALID_ARG,
|
qemudReportError (dom->conn, dom, NULL, VIR_ERR_INVALID_ARG,
|
||||||
_("invalid path: %s"), path);
|
_("invalid path: %s"), path);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qemu_dev_name = qemudDiskDeviceName(dom, disk);
|
||||||
|
if (!qemu_dev_name)
|
||||||
|
return -1;
|
||||||
len = strlen (qemu_dev_name);
|
len = strlen (qemu_dev_name);
|
||||||
|
|
||||||
if (qemudMonitorCommand (driver, vm, "info blockstats", &info) < 0) {
|
if (qemudMonitorCommand (driver, vm, "info blockstats", &info) < 0) {
|
||||||
qemudReportError (dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError (dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
"%s", _("'info blockstats' command failed"));
|
"%s", _("'info blockstats' command failed"));
|
||||||
return -1;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG ("info blockstats reply: %s", info);
|
DEBUG ("info blockstats reply: %s", info);
|
||||||
|
|
||||||
/* If the command isn't supported then qemu prints the supported
|
/* If the command isn't supported then qemu prints the supported
|
||||||
@ -2811,11 +2806,10 @@ qemudDomainBlockStats (virDomainPtr dom,
|
|||||||
* to detect if qemu supports the command.
|
* to detect if qemu supports the command.
|
||||||
*/
|
*/
|
||||||
if (STRPREFIX (info, "info ")) {
|
if (STRPREFIX (info, "info ")) {
|
||||||
free (info);
|
|
||||||
qemudReportError (dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT,
|
qemudReportError (dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT,
|
||||||
"%s",
|
"%s",
|
||||||
_("'info blockstats' not supported by this qemu"));
|
_("'info blockstats' not supported by this qemu"));
|
||||||
return -1;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
stats->rd_req = -1;
|
stats->rd_req = -1;
|
||||||
@ -2866,8 +2860,8 @@ qemudDomainBlockStats (virDomainPtr dom,
|
|||||||
if (!p || p >= eol) break;
|
if (!p || p >= eol) break;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
ret = 0;
|
||||||
goto done;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Skip to next line. */
|
/* Skip to next line. */
|
||||||
@ -2877,14 +2871,12 @@ qemudDomainBlockStats (virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If we reach here then the device was not found. */
|
/* If we reach here then the device was not found. */
|
||||||
free (info);
|
|
||||||
qemudReportError (dom->conn, dom, NULL, VIR_ERR_INVALID_ARG,
|
qemudReportError (dom->conn, dom, NULL, VIR_ERR_INVALID_ARG,
|
||||||
_("device not found: %s (%s)"), path, qemu_dev_name);
|
_("device not found: %s (%s)"), path, qemu_dev_name);
|
||||||
return -1;
|
out:
|
||||||
|
VIR_FREE(qemu_dev_name);
|
||||||
done:
|
VIR_FREE(info);
|
||||||
free (info);
|
return ret;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user