[libvirt] cpu values
by Tavares, John
I am trying to compare the results that I am getting on a RHEL 5.3 server using xm list (using libvirt.so.0.3.3) against both my Dom0 and my Linux DomU on the same server to see if the cpu values match to what the kernel is reporting in /proc/stat. Here is an example of what I am seeing on both:
>From Dom0:
$ sudo /usr/sbin/xm list;cat /proc/stat | grep cpu
Name ID Mem(MiB) VCPUs State Time(s)
Domain-0 0 746 1 r----- 73722.3
rhel5_01 1 255 1 -b---- 18558.4
cpu 412542 1477862 522101 1111350509 347838 0 262 487234
cpu0 412542 1477862 522101 1111350509 347838 0 262 487234
>From DomU (rhelt_01):
$ cat /proc/stat | grep cpu
cpu 138184 148634 246128 924538039 467802 133 178 339822
cpu0 138184 148634 246128 924538039 467802 133 178 339822
The results of the two do not appear close. Should the cpu times match, is this a bug, or does Time mean something different than I think it does??
Thanks.
John
14 years, 8 months
[libvirt] [PATCH] Fix virsh command 'cd'.
by Chris Lalancette
cmdCd was returning a 0 on success and -1 on error, when
the rest of the code expected a TRUE on success and a
FALSE on error. Fix the discrepancy.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
tools/virsh.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index a47edd5..c6e3f2a 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -7469,7 +7469,7 @@ cmdCd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if (!ctl->imode) {
vshError(ctl, "%s", _("cd: command valid only in interactive mode"));
- return -1;
+ return FALSE;
}
dir = vshCommandOptString(cmd, "dir", &found);
@@ -7482,10 +7482,10 @@ cmdCd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if (chdir (dir) == -1) {
vshError(ctl, _("cd: %s: %s"), strerror(errno), dir);
- return -1;
+ return FALSE;
}
- return 0;
+ return TRUE;
}
#endif
--
1.6.6.1
14 years, 8 months
[libvirt] [PATCH] Fix crash in virsh after bogus command.
by Chris Lalancette
If you ran virsh in interactive mode and ran a command
that virsh could not parse, it would then SEGV
on subsequent commands. The problem is that we are
freeing the vshCmd structure in the syntaxError label
at the end of vshCommandParse, but forgetting to
set ctl->cmd to NULL. This means that on the next command,
we would try to free the same structure again, leading
to badness. Make sure to set ctl->cmd to NULL after
freeing it.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
tools/virsh.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index c6e3f2a..eeaddbc 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -8643,8 +8643,10 @@ vshCommandParse(vshControl *ctl, char *cmdstr)
return TRUE;
syntaxError:
- if (ctl->cmd)
+ if (ctl->cmd) {
vshCommandFree(ctl->cmd);
+ ctl->cmd = NULL;
+ }
if (first)
vshCommandOptFree(first);
VIR_FREE(tkdata);
--
1.6.6.1
14 years, 8 months
[libvirt] [PATCH] Fix compiler warnings in virsh.c
by Laine Stump
No functional change. These all generated compiler warnings which, for
some reason weren't converted to errors by
--enable-compiler-warnings=error.
* tools/virsh.c:
* change return type frmo int to void on two functions that don't
return a value.
* remove unused variables/labels from two functions
* eliminate non-literal format strings
* typecast char* into xmlChar* when calling xmlParseBalancedChunkMemory
---
tools/virsh.c | 24 ++++++++++--------------
1 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index a47edd5..33f3647 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -421,7 +421,7 @@ static void vshCatchDisconnect(int sig, siginfo_t * siginfo,
* Catch SIGPIPE signals which may arise when disconnection
* from libvirtd occurs
*/
-static int
+static void
vshSetupSignals(void) {
struct sigaction sig_action;
@@ -435,10 +435,10 @@ vshSetupSignals(void) {
/*
* vshReconnect:
*
- * Reconnect after an
+ * Reconnect after a disconnect from libvirtd
*
*/
-static int
+static void
vshReconnect(vshControl *ctl) {
if (ctl->conn != NULL)
virConnectClose(ctl->conn);
@@ -1896,9 +1896,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
{
virDomainJobInfo info;
virDomainPtr dom;
- int ret = TRUE, autostart;
- unsigned int id;
- char *str, uuid[VIR_UUID_STRING_BUFLEN];
+ int ret = TRUE;
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
return FALSE;
@@ -1980,8 +1978,6 @@ cmdDomjobabort(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
int ret = TRUE;
- unsigned int id;
- char *str, uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
return FALSE;
@@ -1992,7 +1988,6 @@ cmdDomjobabort(vshControl *ctl, const vshCmd *cmd)
if (virDomainAbortJob(dom) < 0)
ret = FALSE;
-cleanup:
virDomainFree(dom);
return ret;
}
@@ -6705,7 +6700,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
}
if (ret != 0) {
- vshError(ctl, _("Failed to attach interface"));
+ vshError(ctl, "%s", _("Failed to attach interface"));
ret = FALSE;
} else {
vshPrint(ctl, "%s", _("Interface attached successfully\n"));
@@ -6834,7 +6829,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
}
if (ret != 0) {
- vshError(ctl, _("Failed to detach interface"));
+ vshError(ctl, "%s", _("Failed to detach interface"));
ret = FALSE;
} else {
vshPrint(ctl, "%s", _("Interface detached successfully\n"));
@@ -7007,7 +7002,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
}
if (ret != 0) {
- vshError(ctl, _("Failed to attach disk"));
+ vshError(ctl, "%s", _("Failed to attach disk"));
ret = FALSE;
} else {
vshPrint(ctl, "%s", _("Disk attached successfully\n"));
@@ -7128,7 +7123,7 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
}
if (ret != 0) {
- vshError(ctl, _("Failed to detach disk"));
+ vshError(ctl, "%s", _("Failed to detach disk"));
ret = FALSE;
} else {
vshPrint(ctl, "%s", _("Disk detached successfully\n"));
@@ -7257,7 +7252,8 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
if (doc == NULL)
goto no_memory;
- res = xmlParseBalancedChunkMemory(doc, NULL, NULL, 0, buffer, &node_list);
+ res = xmlParseBalancedChunkMemory(doc, NULL, NULL, 0,
+ (const xmlChar *)buffer, &node_list);
if (res != 0) {
vshError(ctl, _("Failed to parse XML fragment %s"), from);
ret = FALSE;
--
1.7.0.1
14 years, 8 months
[libvirt] [PATCH] Silence compiler complaints about non-literal format strings
by Laine Stump
* src/util/macvtap.c: replace _("....") with "%s", _("...") in two places
---
src/util/macvtap.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/util/macvtap.c b/src/util/macvtap.c
index 736cbaf..999e670 100644
--- a/src/util/macvtap.c
+++ b/src/util/macvtap.c
@@ -435,13 +435,13 @@ link_add(virConnectPtr conn,
malformed_resp:
ReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("malformed netlink response message"));
+ "%s", _("malformed netlink response message"));
VIR_FREE(recvbuf);
return -1;
buffer_too_small:
ReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("internal buffer is too small"));
+ "%s", _("internal buffer is too small"));
return -1;
}
--
1.7.0.1
14 years, 8 months
[libvirt] Transferring Root File system to Host.
by Kumar L Srikanth-B22348
Hi,
I have a Admin machine on which libvirt client is installed. I want to
manage Virtual Machines[which have a separate rootfs per VM] with the
help of libvirt remote access.
While creating a VM, in the libvirt virsh console, is there any
capability to transfer the rootfs directory on the fly[[like TFTP]],
from the admin machine to host machine which have several other VM's?
Please let me know.
Regards,
Srikanth.
14 years, 8 months
[libvirt] [PATCH] Fix generation of floppy disk arg for QEMU's -global arg
by Daniel P. Berrange
* src/qemu/qemu_conf.c: Fix ',' vs '.' typo in floppy disk arg
---
src/qemu/qemu_conf.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index fb06cd0..beb4386 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -3521,7 +3521,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
char *fdc;
ADD_ARG_LIT("-global");
- if (virAsprintf(&fdc, "isa-fdc,drive%c=drive-%s",
+ if (virAsprintf(&fdc, "isa-fdc.drive%c=drive-%s",
disk->info.addr.drive.unit ? 'B' : 'A',
disk->info.alias) < 0)
goto no_memory;
--
1.6.6
14 years, 8 months
[libvirt] [PATCH] Fix hang in qemudDomainCoreDump.
by Chris Lalancette
Currently if you dump the core of a qemu guest with
qemudDomainCoreDump, subsequent commands will hang
up libvirtd. This is because qemudDomainCoreDump
uses qemuDomainWaitForMigrationComplete, which expects
the qemuDriverLock to be held when it's called. This
patch does the simple thing and moves the qemuDriveUnlock
to the end of the qemudDomainCoreDump so that the driver
lock is held for the entirety of the call (as it is done
in qemudDomainSave). We will probably want to make the
lock more fine-grained than that in the future, but
we can fix both qemudDomainCoreDump and qemudDomainSave
at the same time.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/qemu/qemu_driver.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ee3dbd3..49983dd 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4390,7 +4390,6 @@ static int qemudDomainCoreDump(virDomainPtr dom,
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
- qemuDriverUnlock(driver);
if (!vm) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -4401,7 +4400,7 @@ static int qemudDomainCoreDump(virDomainPtr dom,
}
priv = vm->privateData;
- if (qemuDomainObjBeginJob(vm) < 0)
+ if (qemuDomainObjBeginJobWithDriver(driver, vm) < 0)
goto cleanup;
if (!virDomainObjIsActive(vm)) {
@@ -4499,6 +4498,7 @@ cleanup:
virDomainObjUnlock(vm);
if (event)
qemuDomainEventQueue(driver, event);
+ qemuDriverUnlock(driver);
return ret;
}
--
1.6.6.1
14 years, 8 months
[libvirt] [PATCH] Make sure qemudDomainSetVcpus doesn't hang.
by Chris Lalancette
The code to add job support into libvirtd caused a problem
in qemudDomainSetVcpus. In particular, a qemuDomainObjEndJob()
call was added at the end of the function, but a
corresponding qemuDomainObjBeginJob() was not. Additionally,
a call to qemuDomainObj{Enter,Exit}Monitor() was also missed
in qemudDomainHotplugVcpus(). These missing calls conspired to
cause a hang in the libvirtd process after the command was
finished. Fix this by adding the missing calls.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/qemu/qemu_driver.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 6bfae93..ee3dbd3 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4515,7 +4515,9 @@ static int qemudDomainHotplugVcpus(virDomainObjPtr vm, unsigned int nvcpus)
if (nvcpus > vm->def->vcpus) {
for (i = vm->def->vcpus ; i < nvcpus ; i++) {
/* Online new CPU */
+ qemuDomainObjEnterMonitor(vm);
rc = qemuMonitorSetCPU(priv->mon, i, 1);
+ qemuDomainObjExitMonitor(vm);
if (rc == 0)
goto unsupported;
if (rc < 0)
@@ -4526,7 +4528,9 @@ static int qemudDomainHotplugVcpus(virDomainObjPtr vm, unsigned int nvcpus)
} else {
for (i = vm->def->vcpus - 1 ; i >= nvcpus ; i--) {
/* Offline old CPU */
+ qemuDomainObjEnterMonitor(vm);
rc = qemuMonitorSetCPU(priv->mon, i, 0);
+ qemuDomainObjExitMonitor(vm);
if (rc == 0)
goto unsupported;
if (rc < 0)
@@ -4559,18 +4563,21 @@ static int qemudDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) {
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
qemuDriverUnlock(driver);
+ if (qemuDomainObjBeginJob(vm) < 0)
+ goto cleanup;
+
if (!vm) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(dom->uuid, uuidstr);
qemuReportError(VIR_ERR_NO_DOMAIN,
_("no domain with matching uuid '%s'"), uuidstr);
- goto cleanup;
+ goto endjob;
}
if (!virDomainObjIsActive(vm)) {
qemuReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is not running"));
- goto cleanup;
+ goto endjob;
}
if (!(type = virDomainVirtTypeToString(vm->def->virtType))) {
--
1.6.6.1
14 years, 8 months