Re: [libvirt] Cannot enumerate physical devices with libvirt 0.7.6
by Frédéric Grelot
Yep, here is what I get (see at the end) :
14:06:22.071: debug : do_open:1110 : name "qemu:///system" to URI components:
scheme qemu
opaque (null)
authority (null)
server (null)
user (null)
port 0
path /system
14:06:22.071: debug : do_open:1120 : trying driver 0 (Test) ...
14:06:22.071: debug : do_open:1126 : driver 0 Test returned DECLINED
14:06:22.071: debug : do_open:1120 : trying driver 1 (OPENVZ) ...
14:06:22.071: debug : do_open:1126 : driver 1 OPENVZ returned DECLINED
14:06:22.071: debug : do_open:1120 : trying driver 2 (VBOX) ...
14:06:22.071: debug : do_open:1126 : driver 2 VBOX returned DECLINED
14:06:22.071: debug : do_open:1120 : trying driver 3 (remote) ...
14:06:22.071: debug : do_open:1126 : driver 3 remote returned DECLINED
14:06:22.071: debug : do_open:1120 : trying driver 4 (QEMU) ...
14:06:22.071: debug : do_open:1126 : driver 4 QEMU returned SUCCESS
14:06:22.071: debug : do_open:1146 : network driver 0 Test returned DECLINED
14:06:22.071: debug : do_open:1146 : network driver 1 VBOX returned DECLINED
14:06:22.071: debug : do_open:1146 : network driver 2 remote returned DECLINED
14:06:22.071: debug : do_open:1146 : network driver 3 Network returned SUCCESS
14:06:22.071: debug : do_open:1165 : interface driver 0 Test returned DECLINED
14:06:22.071: debug : do_open:1165 : interface driver 1 remote returned DECLINED
14:06:22.072: debug : do_open:1185 : storage driver 0 Test returned DECLINED
14:06:22.072: debug : do_open:1185 : storage driver 1 VBOX returned DECLINED
14:06:22.072: debug : do_open:1185 : storage driver 2 remote returned DECLINED
14:06:22.072: debug : do_open:1185 : storage driver 3 storage returned SUCCESS
14:06:22.072: debug : do_open:1205 : node driver 0 Test returned DECLINED
14:06:22.072: debug : do_open:1205 : node driver 1 remote returned DECLINED
14:06:22.072: debug : do_open:1232 : secret driver 0 Test returned DECLINED
14:06:22.072: debug : do_open:1232 : secret driver 1 remote returned DECLINED
14:06:22.072: debug : do_open:1232 : secret driver 2 secret returned SUCCESS
14:06:22.072: debug : virConnectClose:1381 : conn=0x1eaf0b0
I think the times when I get those lines matches with my "virsh nodedev-list" requests (or something like this : virt-manager tries to create a vm, add hardware...).
Does this help?
Frederic.
----- "Dave Allan" <dallan(a)redhat.com> a écrit :
> On 02/16/2010 03:00 AM, Frédéric Grelot wrote:
> >> Daniel was referring to the libvirt udev driver--the libvirt code
> that
> >>
> >> interacts with udev--not to udev itself, which is what you're
> testing
> >>
> >> with udevadm.
> >
> > Ok, sorry... At least I ensured that udev itself is on...
> >
> >> In any of your logs when you have libvirt debug logging
> >> turned on, do you see the message:
> >>
> >> Registering udev node device backend
> >
> > Nope, I checked in /var/log/* and libvirt.log in debug mode (which,
> after 1 1/2 day of "debug" activity enabled, is already 2Gb!)
> > There is no mention of udev. I think it means that the udev driver
> is not loaded in libvirt? How could enable it then? (or produce some
> message telling me why it is not) ?
> >
> >
> >> These messages are the result of not being able to find the
> device,
> >> which is consistent with the other things you're seeing. These
> are
> >> all symptoms of the node device code not running.
> >
> > OK, I'll wait for your suggestions...
>
> Do you see messages like:
>
>
> 14:35:01.849: debug : do_open:1205 : node driver 0 Test returned
> DECLINED
> 14:35:01.849: debug : do_open:1205 : node driver 1 ESX returned
> DECLINED
> 14:35:01.849: debug : do_open:1205 : node driver 2 remote returned
> DECLINED
> 14:35:01.849: debug : do_open:1205 : node driver 3 udevDeviceMonitor
> returned SUCCESS
>
> in your debug log?
>
>
> > Frederic.
> >
> >
> >>
> >>> Have you any other Idea?
> >>> Frederic.
> >>>
> >>>
> >>> ----- "Daniel P. Berrange"<berrange(a)redhat.com> a écrit :
> >>>
> >>>> On Fri, Feb 12, 2010 at 08:05:21PM +0100, Fr?d?ric Grelot wrote:
> >>>>> Hi all,
> >>>>>
> >>>>> I often update my F12 box with the rawvirt repository, which
> >>>>> just
> >>>> installed libvirt 0.7.6. Since that, I cannot enumerate physical
> >>>> devices (and thus get a beautiful error when I start one of my
> vms
> >>>> that should use a USB device).
> >>>>>
> >>>>> I don't think I changed anything else on that box, and, of
> >>>>> course, I
> >>>> already restarted the libvirt daemon.
> >>>>> I haven't restarted the server itself, because it is currently
> >>>>> used,
> >>>> but I could do it if necessary...
> >>>>>
> >>>>> I make good use of the qemu hypervisor, and I'm looking forward
> >>>>> to
> >>>> solve this issue!
> >>>>>
> >>>>> Frederic.
> >>>>>
> >>>>> # libvirtd --version libvirtd (libvirt) 0.7.6
> >>>>>
> >>>>> # virsh --version 0.7.6
> >>>>>
> >>>>> # virsh nodedev-list error :Failed to count node devices error
> >>>>> :this function is not supported by the hypervisor:
> >>>> virNodeNumOfDevices
> >>>>
> >>>> It would appear that the udev driver failed to start - there are
> >>>> probably messages in syslog about the problem
> >>>>
> >>>>
> >>>> Regards, Daniel -- |: Red Hat, Engineering, London -o-
> >>>> http://people.redhat.com/berrange/ :| |: http://libvirt.org -o-
> >>>> http://virt-manager.org -o- http://ovirt.org :| |:
> >>>> http://autobuild.org -o- http://search.cpan.org/~danberr/
> :|
> >>>> |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742
> >>>> 7D3B 9505 :|
> >>>
> >>> -- libvir-list mailing list libvir-list(a)redhat.com
> >>> https://www.redhat.com/mailman/listinfo/libvir-list
> >
> > --
> > libvir-list mailing list
> > libvir-list(a)redhat.com
> > https://www.redhat.com/mailman/listinfo/libvir-list
14 years, 9 months
Re: [libvirt] Cannot enumerate physical devices with libvirt 0.7.6
by Frédéric Grelot
The udev driver is actually fully loaded, I even entered "udevadm monitor" in a console, and it reacted as expected when I plugged/unplugged an usb mouse... There is nothing about it in dmesg/boot/message.log, nor libvirt.log (I set up libvirt daemon to log at debug level in /var/log/libvirt/libvirt.log).
By the way, I noticed that libvirt generates tons of "error : qemuMonitorTextGetBlockStatsInfo:698 : invalid argument in no stats found for device virtio-diskX" while virt-manager is running (it stops as soon as I stop virt-manager). Is it linked with the bug I saw on the list about libvirt taking over memory after time isn't it?
Have you any other Idea?
Frederic.
----- "Daniel P. Berrange" <berrange(a)redhat.com> a écrit :
> On Fri, Feb 12, 2010 at 08:05:21PM +0100, Fr?d?ric Grelot wrote:
> > Hi all,
> >
> > I often update my F12 box with the rawvirt repository, which just
> installed libvirt 0.7.6. Since that, I cannot enumerate physical
> devices (and thus get a beautiful error when I start one of my vms
> that should use a USB device).
> >
> > I don't think I changed anything else on that box, and, of course, I
> already restarted the libvirt daemon.
> > I haven't restarted the server itself, because it is currently used,
> but I could do it if necessary...
> >
> > I make good use of the qemu hypervisor, and I'm looking forward to
> solve this issue!
> >
> > Frederic.
> >
> > # libvirtd --version
> > libvirtd (libvirt) 0.7.6
> >
> > # virsh --version
> > 0.7.6
> >
> > # virsh nodedev-list
> > error :Failed to count node devices
> > error :this function is not supported by the hypervisor:
> virNodeNumOfDevices
>
> It would appear that the udev driver failed to start - there are
> probably
> messages in syslog about the problem
>
>
> Regards,
> Daniel
> --
> |: Red Hat, Engineering, London -o-
> http://people.redhat.com/berrange/ :|
> |: http://libvirt.org -o- http://virt-manager.org -o-
> http://ovirt.org :|
> |: http://autobuild.org -o-
> http://search.cpan.org/~danberr/ :|
> |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B
> 9505 :|
14 years, 9 months
[libvirt] [PATCH] vshCommandParse: placate coverity
by Jim Meyering
Here are two patches to avoid semblance of a leak.
One adds a useless use of VIR_FREE.
The other adds an assertion that the pointer to would-be-leaked
storage is NULL. There's already an assertion in this file,
so no need to add an "#include ...".
Take your pick.
>From 2070262e7f1a4803e06a6f75bd96091c5754164d Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 16 Feb 2010 14:34:48 +0100
Subject: [PATCH] vshCommandParse: placate coverity
There is no real leak here, but Coverity-Prevent thinks there is.
It does not see that while there are four ways to return from
vshCommandGetToken with VSH_TK_END, none of them results in allocation
of a result.
* tools/virsh.c (vshCommandParse): Add a (currently) useless VIR_FREE,
to ensure that we never leak when vshCommandGetToken returns VSH_TK_END.
---
tools/virsh.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 7db48d9..4ffa154 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -8222,8 +8222,10 @@ vshCommandParse(vshControl *ctl, char *cmdstr)
str = end;
- if (tk == VSH_TK_END)
+ if (tk == VSH_TK_END) {
+ VIR_FREE(tkdata);
break;
+ }
if (tk == VSH_TK_ERROR)
goto syntaxError;
--
1.7.0.181.g41533
>From 98b0c148d7fd7e11eed7786189db60b485612b51 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 16 Feb 2010 14:34:48 +0100
Subject: [PATCH] vshCommandParse: placate coverity
* tools/virsh.c (vshCommandParse): Inform static analyzers that
there is no risk of leak when vshCommandGetToken returns VSH_TK_END.
---
tools/virsh.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 7db48d9..5c45d1c 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -8222,8 +8222,10 @@ vshCommandParse(vshControl *ctl, char *cmdstr)
str = end;
- if (tk == VSH_TK_END)
+ if (tk == VSH_TK_END) {
+ assert (tkdata == NULL);
break;
+ }
if (tk == VSH_TK_ERROR)
goto syntaxError;
--
1.7.0.181.g41533
14 years, 9 months
[libvirt] [PATCH] qemuMonitorTextAddUSBDisk: avoid unconditional leak
by Jim Meyering
First the patch, then the (fixed) function:
>From d3f0ee1ee11ca5f3709168fdc4e6eb1c56fdfbc0 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 16 Feb 2010 13:51:38 +0100
Subject: [PATCH] qemuMonitorTextAddUSBDisk: avoid unconditional leak
* src/qemu/qemu_monitor_text.c (qemuMonitorTextAddUSBDisk): Free
command output buffer.
---
src/qemu/qemu_monitor_text.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index c71bf1d..62ffcc6 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -1229,6 +1229,7 @@ int qemuMonitorTextAddUSBDisk(qemuMonitorPtr mon,
cleanup:
VIR_FREE(cmd);
VIR_FREE(safepath);
+ VIR_FREE(info);
return ret;
}
--
1.7.0.181.g41533
int qemuMonitorTextAddUSBDisk(qemuMonitorPtr mon,
const char *path)
{
char *cmd = NULL;
char *safepath;
int ret = -1;
char *info = NULL;
safepath = qemuMonitorEscapeArg(path);
if (!safepath) {
virReportOOMError();
return -1;
}
if (virAsprintf(&cmd, "usb_add disk:%s", safepath) < 0) {
virReportOOMError();
goto cleanup;
}
if (qemuMonitorCommand(mon, cmd, &info) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot run monitor command to add usb disk"));
goto cleanup;
}
/* If the command failed qemu prints:
* Could not add ... */
if (strstr(info, "Could not add ")) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
_("unable to add USB disk %s: %s"), path, info);
goto cleanup;
}
ret = 0;
cleanup:
VIR_FREE(cmd);
VIR_FREE(safepath);
VIR_FREE(info);
return ret;
}
14 years, 9 months
[libvirt] [PATCH] tests: avoid NULL deref upon OOM failure
by Jim Meyering
Pretty obvious:
>From 3e79d8839c5051461197a7c484adb32f7f04377a Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 16 Feb 2010 09:36:57 +0100
Subject: [PATCH] tests: avoid NULL deref upon OOM failure
* tests/qemuxml2argvtest.c (testCompareXMLToArgvFiles): Handle malloc
failure.
---
tests/qemuxml2argvtest.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 3ee71a3..aa42f99 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -98,7 +98,8 @@ static int testCompareXMLToArgvFiles(const char *xml,
len += strlen(*tmp) + 1;
tmp++;
}
- actualargv = malloc(sizeof(*actualargv)*len);
+ if ((actualargv = malloc(sizeof(*actualargv)*len)) == NULL)
+ goto fail;
actualargv[0] = '\0';
tmp = qenv;
while (*tmp) {
--
1.7.0.181.g41533
14 years, 9 months
[libvirt] [PATCH] qemuInitPasswords: avoid unconditional leak
by Jim Meyering
A successful getVolumeQcowPassphrase allocates "secret".
Nothing freed it.
>From 2aa6d3c4254f587133e473f4d193ccb023507665 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 16 Feb 2010 09:22:02 +0100
Subject: [PATCH] qemuInitPasswords: avoid unconditional leak
* src/qemu/qemu_driver.c (qemuInitPasswords): Free pass-phrase buffer.
---
src/qemu/qemu_driver.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 03feaf4..e8b7cf6 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1733,34 +1733,35 @@ qemuInitPasswords(virConnectPtr conn,
for (i = 0 ; i < vm->def->ndisks ; i++) {
char *secret;
size_t secretLen;
if (!vm->def->disks[i]->encryption ||
!vm->def->disks[i]->src)
continue;
if (getVolumeQcowPassphrase(conn,
vm->def->disks[i],
&secret, &secretLen) < 0)
goto cleanup;
qemuDomainObjEnterMonitorWithDriver(driver, vm);
ret = qemuMonitorSetDrivePassphrase(priv->mon,
vm->def->disks[i]->info.alias,
secret);
+ VIR_FREE(secret);
qemuDomainObjExitMonitorWithDriver(driver, vm);
if (ret < 0)
goto cleanup;
}
}
cleanup:
return ret;
}
#define QEMU_PCI_VENDOR_INTEL 0x8086
#define QEMU_PCI_VENDOR_LSI_LOGIC 0x1000
#define QEMU_PCI_VENDOR_REDHAT 0x1af4
#define QEMU_PCI_VENDOR_CIRRUS 0x1013
#define QEMU_PCI_VENDOR_REALTEK 0x10ec
#define QEMU_PCI_VENDOR_AMD 0x1022
--
1.7.0.181.g41533
14 years, 9 months
[libvirt] [PATCH] qemuMonitorTextAddDevice: avoid unconditional leak
by Jim Meyering
Here's the patch (entire function below):
>From 1ee0edab5356ca8cd84a88e4e4a2e4f3cd916f57 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 16 Feb 2010 08:22:34 +0100
Subject: [PATCH] qemuMonitorTextAddDevice: avoid unconditional leak
* src/qemu/qemu_monitor_text.c (qemuMonitorTextAddDevice): Free the
device name buffer.
---
src/qemu/qemu_monitor_text.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index e993699..c71bf1d 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -2087,6 +2087,7 @@ int qemuMonitorTextAddDevice(qemuMonitorPtr mon,
cleanup:
VIR_FREE(cmd);
VIR_FREE(reply);
+ VIR_FREE(safedev);
return ret;
}
--
1.7.0.181.g41533
For reference, here's the entire function:
int qemuMonitorTextAddDevice(qemuMonitorPtr mon,
const char *devicestr)
{
char *cmd = NULL;
char *reply = NULL;
char *safedev;
int ret = -1;
if (!(safedev = qemuMonitorEscapeArg(devicestr))) {
virReportOOMError();
goto cleanup;
}
if (virAsprintf(&cmd, "device_add %s", safedev) < 0) {
virReportOOMError();
goto cleanup;
}
if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
_("cannot attach %s device"), devicestr);
goto cleanup;
}
if (STRNEQ(reply, "")) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
_("adding %s device failed: %s"), devicestr, reply);
goto cleanup;
}
ret = 0;
cleanup:
VIR_FREE(cmd);
VIR_FREE(reply);
VIR_FREE(safedev);
return ret;
}
14 years, 9 months
[libvirt] PATCH [0/3] Volume zeroing
by David Allan
The following patches implement overwriting a volume with zeros when
the volume is deleted. The zeroing happens before the delete, so it
works for storage backends that don't support actually deleting
volumes as well as the ones that do. The intent is that any future VM
assigned that volume will not be able to recover any data belonging to
the previous VM. It is not intended to prevent attackers with
physical access to the medium from recovering data--it simply writes a
single pass of zeros over the medium.
If the filesystem containing the volume supports the fiemap ioctl and
the volume is a sparse file, the volume zeroing code attempts to use
fiemap to locate the mapped extents. It does not attempt to zero a
sparse file if it cannot use fiemap. Such an operation could take an
essentially unbounded amount of time.
Since the volume is being deleted, zeroing has less value in the
context of backends that support delete, but does provide value with
storage backends that do not zero volumes if they are deleted and
recreated.
Dave
14 years, 9 months
[libvirt] [PATCH] Support VCPU hotplug in QEMU guests
by Daniel P. Berrange
QEMU has a monitor command 'set_cpu' which allows a specific
CPU to be toggled between online& offline state. libvirt CPU
hotplug does not work in terms of individual indexes CPUs.
Thus to support this, we iteratively toggle the online state
when the total number of vCPUs is adjusted via libvirt
NB, currently untested since QEMU segvs when running this!
* src/qemu/qemu_driver.c: Toggle online state for CPUs when
doing hotplug
* 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: Add
monitor API for toggling a CPU's online status via 'set_cpu
---
src/qemu/qemu_driver.c | 59 ++++++++++++++++++++++++++++++++++++-----
src/qemu/qemu_monitor.c | 14 ++++++++++
src/qemu/qemu_monitor.h | 2 +
src/qemu/qemu_monitor_json.c | 44 +++++++++++++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 1 +
src/qemu/qemu_monitor_text.c | 38 +++++++++++++++++++++++++++
src/qemu/qemu_monitor_text.h | 1 +
7 files changed, 151 insertions(+), 8 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 03feaf4..6ef784f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4206,6 +4206,51 @@ cleanup:
}
+static int qemudDomainHotplugVcpus(virDomainObjPtr vm, unsigned int nvcpus)
+{
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+ int i, rc;
+ int ret = -1;
+
+ /* We need different branches here, because we want to offline
+ * in reverse order to onlining, so any partial fail leaves us in a
+ * reasonably sensible state */
+ if (nvcpus > vm->def->vcpus) {
+ for (i = vm->def->vcpus ; i < nvcpus ; i++) {
+ /* Online new CPU */
+ rc = qemuMonitorSetCPU(priv->mon, i, 1);
+ if (rc == 0)
+ goto unsupported;
+ if (rc < 0)
+ goto cleanup;
+
+ vm->def->vcpus++;
+ }
+ } else {
+ for (i = vm->def->vcpus - 1 ; i >= nvcpus ; i--) {
+ /* Offline old CPU */
+ rc = qemuMonitorSetCPU(priv->mon, i, 0);
+ if (rc == 0)
+ goto unsupported;
+ if (rc < 0)
+ goto cleanup;
+
+ vm->def->vcpus--;
+ }
+ }
+
+ ret = 0;
+
+cleanup:
+ return ret;
+
+unsupported:
+ qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_INVALID, "%s",
+ _("cannot change vcpu count of an active domain"));
+ goto cleanup;
+}
+
+
static int qemudDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) {
struct qemud_driver *driver = dom->conn->privateData;
virDomainObjPtr vm;
@@ -4228,12 +4273,6 @@ static int qemudDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) {
if (qemuDomainObjBeginJob(vm) < 0)
goto cleanup;
- if (virDomainObjIsActive(vm)) {
- qemuReportError(VIR_ERR_OPERATION_INVALID, "%s",
- _("cannot change vcpu count of an active domain"));
- goto endjob;
- }
-
if (!(type = virDomainVirtTypeToString(vm->def->virtType))) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown virt type in domain definition '%d'"),
@@ -4254,8 +4293,12 @@ static int qemudDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) {
goto endjob;
}
- vm->def->vcpus = nvcpus;
- ret = 0;
+ if (virDomainObjIsActive(vm)) {
+ ret = qemudDomainHotplugVcpus(vm, nvcpus);
+ } else {
+ vm->def->vcpus = nvcpus;
+ ret = 0;
+ }
endjob:
if (qemuDomainObjEndJob(vm) == 0)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index c1d369b..541d7a1 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -912,6 +912,20 @@ int qemuMonitorSetBalloon(qemuMonitorPtr mon,
return ret;
}
+
+int qemuMonitorSetCPU(qemuMonitorPtr mon, int cpu, int online)
+{
+ int ret;
+ DEBUG("mon=%p, fd=%d cpu=%d online=%d", mon, mon->fd, cpu, online);
+
+ if (mon->json)
+ ret = qemuMonitorJSONSetCPU(mon, cpu, online);
+ else
+ ret = qemuMonitorTextSetCPU(mon, cpu, online);
+ return ret;
+}
+
+
int qemuMonitorEjectMedia(qemuMonitorPtr mon,
const char *devname)
{
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 786ad7a..d560c63 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -144,6 +144,8 @@ int qemuMonitorSetVNCPassword(qemuMonitorPtr mon,
const char *password);
int qemuMonitorSetBalloon(qemuMonitorPtr mon,
unsigned long newmem);
+int qemuMonitorSetCPU(qemuMonitorPtr mon, int cpu, int online);
+
/* XXX should we pass the virDomainDiskDefPtr instead
* and hide devname details inside monitor. Reconsider
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index c9b8d60..35e529e 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -873,6 +873,50 @@ cleanup:
}
+/*
+ * Returns: 0 if CPU hotplug not supported, +1 if CPU hotplug worked
+ * or -1 on failure
+ */
+int qemuMonitorJSONSetCPU(qemuMonitorPtr mon,
+ int cpu, int online)
+{
+ int ret;
+ virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("balloon",
+ "U:cpu", (unsigned long long)cpu,
+ "s:state", online ? "online" : "offline",
+ NULL);
+ virJSONValuePtr reply = NULL;
+ if (!cmd)
+ return -1;
+
+ ret = qemuMonitorJSONCommand(mon, cmd, &reply);
+
+ if (ret == 0) {
+ /* XXX See if CPU soft-failed due to lack of ACPI */
+#if 0
+ if (qemuMonitorJSONHasError(reply, "DeviceNotActive") ||
+ qemuMonitorJSONHasError(reply, "KVMMissingCap"))
+ goto cleanup;
+#endif
+
+ /* See if any other fatal error occurred */
+ ret = qemuMonitorJSONCheckError(cmd, reply);
+
+ /* Real success */
+ if (ret == 0)
+ ret = 1;
+ }
+
+#if 0
+cleanup:
+#endif
+
+ virJSONValueFree(cmd);
+ virJSONValueFree(reply);
+ return ret;
+}
+
+
int qemuMonitorJSONEjectMedia(qemuMonitorPtr mon,
const char *devname)
{
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 65a70e3..88dfd3c 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -57,6 +57,7 @@ int qemuMonitorJSONSetVNCPassword(qemuMonitorPtr mon,
const char *password);
int qemuMonitorJSONSetBalloon(qemuMonitorPtr mon,
unsigned long newmem);
+int qemuMonitorJSONSetCPU(qemuMonitorPtr mon, int cpu, int online);
int qemuMonitorJSONEjectMedia(qemuMonitorPtr mon,
const char *devname);
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index e993699..1745b20 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -797,6 +797,44 @@ int qemuMonitorTextSetBalloon(qemuMonitorPtr mon,
return ret;
}
+
+/*
+ * Returns: 0 if balloon not supported, +1 if balloon adjust worked
+ * or -1 on failure
+ */
+int qemuMonitorTextSetCPU(qemuMonitorPtr mon, int cpu, int online)
+{
+ char *cmd;
+ char *reply = NULL;
+ int ret = -1;
+
+ if (virAsprintf(&cmd, "set_cpu %d %s", cpu, online ? "online" : "offline") < 0) {
+ virReportOOMError(NULL);
+ return -1;
+ }
+
+ if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
+ qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
+ "%s", _("could nt change CPU online status"));
+ VIR_FREE(cmd);
+ return -1;
+ }
+ VIR_FREE(cmd);
+
+ /* If the command failed qemu prints: 'unknown command'
+ * No message is printed on success it seems */
+ if (strstr(reply, "\nunknown command:")) {
+ /* Don't set error - it is expected CPU onlining fails on many qemu - caller will handle */
+ ret = 0;
+ } else {
+ ret = 1;
+ }
+
+ VIR_FREE(reply);
+ return ret;
+}
+
+
int qemuMonitorTextEjectMedia(qemuMonitorPtr mon,
const char *devname)
{
diff --git a/src/qemu/qemu_monitor_text.h b/src/qemu/qemu_monitor_text.h
index 1937e99..77b8b0f 100644
--- a/src/qemu/qemu_monitor_text.h
+++ b/src/qemu/qemu_monitor_text.h
@@ -61,6 +61,7 @@ int qemuMonitorTextSetVNCPassword(qemuMonitorPtr mon,
const char *password);
int qemuMonitorTextSetBalloon(qemuMonitorPtr mon,
unsigned long newmem);
+int qemuMonitorTextSetCPU(qemuMonitorPtr mon, int cpu, int online);
int qemuMonitorTextEjectMedia(qemuMonitorPtr mon,
const char *devname);
--
1.6.6
14 years, 9 months
Re: [libvirt] Live Migration with non-shared storage for kvm
by Kenneth Nagin
>"Daniel P. Berrange" <berrange(a)redhat.com> wrote on 26/01/2010 16:20:22:
> "Daniel P. Berrange" <berrange(a)redhat.com>
> 26/01/2010 16:20
>
> Please respond to
> "Daniel P. Berrange" <berrange(a)redhat.com>
>
> To
>
> Kenneth Nagin/Haifa/IBM@IBMIL
>
> cc
>
> Subject
>
> Re: [libvirt] Live Migration with non-shared storage for kvm
>
> On Tue, Jan 26, 2010 at 04:09:58PM +0200, Kenneth Nagin wrote:
> > "Daniel P. Berrange" <berrange(a)redhat.com> wrote on 26/01/2010
12:14:47:
> > Since, this my first time submitting something to libvirt I wanted to
make
> > the initially submission simple, i.e. just adding the flags.
>
> That sounds fine
>
> > >
> > > > I suggest adding these flags to virDomainMigrate.
> > >
> > > That sounds reasonable.
> > >
> > > > If I'm not mistaken qemuMonitorTextMigrate is the function that
> > actually
> > > > invokes the kvm monitor.
> > > > Thus, it would be necessary to pass the flags to
> > qemuMonitorTextMigrate..
> > > > But qemuMonitorTextMigrate does not have a flag input parameter. I
> > think
> > > > the least disruptive way to support the new flags is use the
existing
> > > > "background" parameter
> > > > to pass the flags. Of course this would require some changes to
the
> > > > upstream functions that are invoked for migration.
> > >
> > > That is an internal function, so adding extra parameters to it is no
> > > problem at all - no need to reuse/abuse existing parameters.
> > >
> > Are you recommending adding another "flag" parameter or exploiting the
> > existing "background" parameter?
>
> Probably define some flags for the internal API. eg in
src/qemu/qemu_monitor.h
> add a small enum
>
> enum {
> QEMU_MONITOR_MIGRATE_BACKGROUND = 1 << 0,
> QEMU_MONITOR_MIGRATE_STORAGE = 1 << 1
> ...etc
> };
>
> and then just replace the existing background parameter with a flags
> parameter
>
>
> Daniel
> --
> |: Red Hat, Engineering, London -o-
http://people.redhat.com/berrange/ :|
> |: http://libvirt.org -o- http://virt-manager.org -o-
http://ovirt.org :|
> |: http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
> |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B
9505 :|
Sorry about the delayed response. I had some pressing work items and
family issues that took precedence.
In order to support kvm's live migration with non-shared storage I added
two
migration flags that user can invoke:
VIR_MIGRATE_NON_SHARED_DISK = (1 << 6), /* migration with non-shared
storage with full disk copy */
VIR_MIGRATE_NON_SHARED_INC = (1 << 7), /* migration with non-shared
storage with incremental copy */
/* (same base image shared
between source and destination) */
Likewise I add complementary flags to virsh migrate: non_shared_disk and
non_shared_inc
As you suggested I also added internal flags to be passed in the
"background" parameter to the qemu monitor:
typedef enum {
QEMU_MONITOR_MIGRATE_BACKGROUND = 1 << 0,
QEMU_MONITOR_MIGRATE_NON_SHARED_DISK = 1 << 1, /* migration with
non-shared storage with full disk copy */
QEMU_MONITOR_MIGRATE_NON_SHARED_INC = 1 << 2, /* migration with
non-shared storage with incremental copy */
QEMU_MONITOR_MIGRATION_FLAGS_LAST
};
I updated qemu_driver.c's doNativeMigrate and doTunnelMigrate to map the
external flags to the internal flags.
I updated qemu_monitor_text's qemuMonitorTextMigrate to map the internal
flags to the qemu monitor's command line flags.
I tested the doNativeMigrate usage of the two flags. However, I could not
test the doTunnelMigrate usage because I wasn't sure how it works. Also,
qemudDomainSave ends up calling qemuMonitorTextMigrate, but it didn't
support the external flags so I assumed that it was not relevant.
Here is the diff patch file from the current git:
(See attached file: migration_with_non_shared.patch)
- Kenneth Nagin
14 years, 9 months