[libvirt] [PATCH RESEND] qemu: Do not free the device from activePciHostdevs if it's in use
by Osier Yang
* src/qemu/qemu_hostdev.c (qemuDomainReAttachHostdevDevices):
pciDeviceListFree(pcidevs) in the end free()s the device even if
it's in use by other domain, which can cause rase.
How to reproduce:
<script>
virsh nodedev-dettach pci_0000_00_19_0
virsh start test
virsh attach-device test hostdev.xml
virsh start test2
for i in {1..5}; do
echo "[ -- ${i}th time --]"
virsh nodedev-reattach pci_0000_00_19_0
done
echo "clean up"
virsh destroy test
virsh nodedev-reattach pci_0000_00_19_0
</script>
Device pci_0000_00_19_0 dettached
Domain test started
Device attached successfully
error: Failed to start domain test2
error: Requested operation is not valid: PCI device 0000:00:19.0 is in use by domain test
[ -- 1th time --]
Device pci_0000_00_19_0 re-attached
[ -- 2th time --]
Device pci_0000_00_19_0 re-attached
[ -- 3th time --]
Device pci_0000_00_19_0 re-attached
[ -- 4th time --]
Device pci_0000_00_19_0 re-attached
[ -- 5th time --]
Device pci_0000_00_19_0 re-attached
clean up
Domain test destroyed
Device pci_0000_00_19_0 re-attached
The patch also fixes another problem, there won't be error like
"qemuDomainReAttachHostdevDevices: Not reattaching active
device 0000:00:19.0" in daemon log if some device is in active.
As pciResetDevice and pciReattachDevice won't be called for
the device anymore. This is sensiable as we already reported
error when preparing the device if it's active. Blindly trying
to pciResetDevice & pciReattachDevice on the device and getting
an error is just redundant.
---
src/qemu/qemu_hostdev.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index 9137388..60401f0 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -414,8 +414,10 @@ void qemuDomainReAttachHostdevDevices(struct qemud_driver *driver,
*/
activeDev = pciDeviceListFind(driver->activePciHostdevs, dev);
if (activeDev &&
- STRNEQ_NULLABLE(name, pciDeviceGetUsedBy(activeDev)))
+ STRNEQ_NULLABLE(name, pciDeviceGetUsedBy(activeDev))) {
+ pciDeviceListSteal(pcidevs, dev);
continue;
+ }
/* pciDeviceListFree() will take care of freeing the dev. */
pciDeviceListSteal(driver->activePciHostdevs, dev);
--
1.7.7.3
12 years, 11 months
[libvirt] [PATCH RESEND] qemu: Honor the original properties of PCI device when detaching
by Osier Yang
This patch fixes two problems:
1) The device will be reattached to host even if it's not
managed, as there is a "pciDeviceSetManaged".
2) The device won't be reattached to host with original
driver properly. As it doesn't honor the device original
properties which are maintained by driver->activePciHostdevs.
---
src/qemu/qemu_hotplug.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 96c0070..19e4a41 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1960,6 +1960,7 @@ int qemuDomainDetachHostPciDevice(struct qemud_driver *driver,
qemuDomainObjPrivatePtr priv = vm->privateData;
int i, ret;
pciDevice *pci;
+ pciDevice *activePci;
for (i = 0 ; i < vm->def->nhostdevs ; i++) {
if (vm->def->hostdevs[i]->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
@@ -2019,16 +2020,16 @@ int qemuDomainDetachHostPciDevice(struct qemud_driver *driver,
detach->source.subsys.u.pci.bus,
detach->source.subsys.u.pci.slot,
detach->source.subsys.u.pci.function);
- if (!pci)
- ret = -1;
- else {
- pciDeviceSetManaged(pci, detach->managed);
- pciDeviceListDel(driver->activePciHostdevs, pci);
- if (pciResetDevice(pci, driver->activePciHostdevs, NULL) < 0)
+ if (pci) {
+ activePci = pciDeviceListSteal(driver->activePciHostdevs, pci);
+ if (pciResetDevice(activePci, driver->activePciHostdevs, NULL))
+ qemuReattachPciDevice(activePci, driver);
+ else
ret = -1;
- pciDeviceReAttachInit(pci);
- qemuReattachPciDevice(pci, driver);
pciFreeDevice(pci);
+ pciFreeDevice(activePci);
+ } else {
+ ret = -1;
}
if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE) &&
--
1.7.7.3
12 years, 11 months
[libvirt] [PATCH 0/4] Add support for QEMU guest agent control
by Daniel P. Berrange
The QEMU guest agent "/usr/bin/qemu-ga" has some handy functions
for controlling the guest, not least, shutdown/reboot and filesystem
freeze/thaw.
In Fedora 15/16 the semantics of the ACPI power button have been
changed to suspend-to-RAM which breaks our current shutdown
implementation.
By adding support for the agent we gain a more predictable way
to shutdown / reboot guests.
NB: the code currently has the same "flaw" as the monitor, in
so much as we wait forever for a guest agent reply. We need to
add a timeout ability to the agent code
12 years, 11 months
[libvirt] macvtap nt working on kvm
by Amit Tewari
Hi all,
My test environment
Host os=rhel6.1
Guest os = rhel6.1
Libvirt=0.8.7
Kvm hypervisor
I have made this entry in guest xml file
<interface type='direct'>
<source dev='eth0' mode='bridge'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03'
function='0x0'/>
</interface>
Now when I start the guest
#virsh start guest
Following macvtap0 is created on host and is shown below
#ip link show macvtap0
51: macvtap0@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq
state UNKNOWN qlen 500
link/ether 52:54:00:55:AE:B5brd ff:ff:ff:ff:ff:ff
but when the guest is up and I try to perform
# ifup eth0
eth0 has same mac address as that of macvatap0 that is
52:54:00:55:AE:B5
due to this guest is not able to get dhcp address nor static ip address
is working.
Please let me know how macvtap work on kvm.
DISCLAIMER:
-----------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and
intended
for the named recipient(s) only.
It shall not attach any liability on the originator or NECHCL or its
affiliates. Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the
opinions of NECHCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification,
distribution and / or publication of
this message without the prior written consent of the author of this e-mail is
strictly prohibited. If you have
received this email in error please delete it and notify the sender
immediately. .
-----------------------------------------------------------------------------------------------------------------------
12 years, 11 months
Re: [libvirt] libvirt support on QNX
by Chandrashekhar Jamadarkhani (cjamadar)
Config.h file is missing in qnx. What is the path to config.h in linux ?
Build Error (pasted here for one file only)
src/util/iptables.c:22:20: error: config.h: No such file or directory
Thanks,
Chandrashekhar
-----Original Message-----
From: Chandrashekhar Jamadarkhani (cjamadar)
Sent: Wednesday, December 14, 2011 3:24 PM
To: 'Daniel P. Berrange'
Subject: RE: libvirt support on QNX
Thanks Daniel ! We are using Jamfile instead of Makefile in our build environment. Let me check how can I build the same in our build environment.
Thanks,
Chandarshekhar
-----Original Message-----
From: Daniel P. Berrange [mailto:berrange@redhat.com]
Sent: Wednesday, December 14, 2011 2:56 PM
To: Chandrashekhar Jamadarkhani (cjamadar)
Subject: Re: libvirt support on QNX
On Wed, Dec 14, 2011 at 02:50:31PM +0530, Chandrashekhar Jamadarkhani (cjamadar) wrote:
> Thanks Daniel. I should port only src/rpc to QNX or anything else I need to port to QNX ?
You basically want to build with
./configure \
--enable-compile-warnings=error \
--without-xen \
--without-qemu \
--without-openvz \
--without-lxc \
--without-vbox \
--without-xenapi \
--without-esx \
--without-uml \
--without-sasl \
--without-avahi \
--without-polkit \
--without-python \
--without-libvirtd \
--without-phyp \
--without-hyperv \
--without-netcf \
--without-audit \
--without-dtrace
And then fix whatever fails to build (if anything).
This should only be stuff in
src/util
src/conf
src/rpc
src/remote
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
12 years, 11 months
[libvirt] [PATCH 0/3] spec file fixes
by Eric Blake
Several spec file patches that I've noticed by comparing against
open BZs and existing RPMs. Probably all worth including in 0.9.8,
but I'm not comfortable pushing them without a review.
Eric Blake (3):
spec: always autoreconf when building rpm
spec: add dmidecode as prereq
spec: fix sanlock dependency
libvirt.spec.in | 30 +++++++++++++++++++++---------
1 files changed, 21 insertions(+), 9 deletions(-)
--
1.7.7.3
12 years, 11 months
[libvirt] [PATCH] python: Expose blockPeek and memoryPeek in Python binding
by Osier Yang
An simple example to show to use it:
\#! /usr/bin/python
import os
import sys
import libvirt
disk = "/var/lib/libvirt/images/test.img"
conn = libvirt.open(None)
dom = conn.lookupByName('test')
mem_contents = dom.memoryPeek(0, 128, libvirt.VIR_MEMORY_VIRTUAL);
sys.stdout.write(mem_contents)
% python test.py | hexdump
0000000 1660 0209 0000 0000 0000 0000 0000 0000
0000010 0000 0000 0000 0000 d3a0 01d0 0000 0000
0000020
---
python/generator.py | 1 +
python/libvirt-override-api.xml | 17 +++++++++
python/libvirt-override.c | 75 +++++++++++++++++++++++++++++++++++++++
3 files changed, 93 insertions(+), 0 deletions(-)
diff --git a/python/generator.py b/python/generator.py
index 88c52b9..1657f4f 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -262,6 +262,7 @@ py_types = {
'unsigned char *': ('z', None, "charPtr", "char *"),
'char *': ('z', None, "charPtr", "char *"),
'const char *': ('z', None, "charPtrConst", "const char *"),
+ 'size_t': ('n', None, "size_t", "size_t"),
'virDomainPtr': ('O', "virDomain", "virDomainPtr", "virDomainPtr"),
'const virDomainPtr': ('O', "virDomain", "virDomainPtr", "virDomainPtr"),
diff --git a/python/libvirt-override-api.xml b/python/libvirt-override-api.xml
index 7c18763..2e0c7cb 100644
--- a/python/libvirt-override-api.xml
+++ b/python/libvirt-override-api.xml
@@ -405,5 +405,22 @@
<arg name='flags' type='unsigned int' info='an OR'ed set of virDomainModificationImpact'/>
<return type='int' info='0 in case of success, -1 in case of failure'/>
</function>
+ <function name='virDomainBlockPeek' file='python'>
+ <info>Read the contents of domain's disk device</info>
+ <arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
+ <arg name='disk' type='const char *' info='disk name'/>
+ <arg name='offset' type='unsigned long long' info='offset within block device'/>
+ <arg name='size' type='size_t' info='size to read'/>
+ <arg name='flags' type='unsigned int' info='unused, always passed 0'/>
+ <return type='char *' info='the returned buffer or None in case of error'/>
+ </function>
+ <function name='virDomainMemoryPeek' file='python'>
+ <info>Read the contents of domain's memory</info>
+ <arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
+ <arg name='start' type='unsigned long long' info='start of memory to peek'/>
+ <arg name='size' type='size_t' info='size of memory to peek'/>
+ <arg name='flags' type='unsigned int' info='an OR'ed set of virDomainMemoryFlags'/>
+ <return type='char *' info='the returned buffer or None in case of error'/>
+ </function>
</symbols>
</api>
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index 9e98918..64d7943 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -5017,6 +5017,79 @@ libvirt_virDomainMigrateGetMaxSpeed(PyObject *self ATTRIBUTE_UNUSED, PyObject *a
return(py_retval);
}
+static PyObject *
+libvirt_virDomainBlockPeek(PyObject *self ATTRIBUTE_UNUSED,
+ PyObject *args) {
+ PyObject *py_retval = NULL;
+ int c_retval;
+ virDomainPtr domain;
+ PyObject *pyobj_domain;
+ const char *disk;
+ unsigned long long offset;
+ size_t size;
+ char *buf;
+ unsigned int flags;
+
+ if (!PyArg_ParseTuple(args, (char *)"OzLni:virDomainBlockPeek", &pyobj_domain,
+ &disk, &offset, &size, &flags))
+ return(NULL);
+
+ domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+ if ((buf = malloc(size)) == NULL)
+ return VIR_PY_NONE;
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ c_retval = virDomainBlockPeek(domain, disk, offset, size, buf, flags);
+ LIBVIRT_END_ALLOW_THREADS;
+
+ if (c_retval < 0)
+ goto cleanup;
+
+ py_retval = PyString_FromStringAndSize(buf, size);
+
+cleanup:
+ memset(buf, 0, size);
+ free(buf);
+ return py_retval;
+}
+
+static PyObject *
+libvirt_virDomainMemoryPeek(PyObject *self ATTRIBUTE_UNUSED,
+ PyObject *args) {
+ PyObject *py_retval = NULL;
+ int c_retval;
+ virDomainPtr domain;
+ PyObject *pyobj_domain;
+ unsigned long long start;
+ size_t size;
+ char *buf;
+ unsigned int flags;
+
+ if (!PyArg_ParseTuple(args, (char *)"OLni:virDomainMemoryPeek", &pyobj_domain,
+ &start, &size, &flags))
+ return(NULL);
+
+ domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+ if ((buf = malloc(size)) == NULL)
+ return VIR_PY_NONE;
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ c_retval = virDomainMemoryPeek(domain, start, size, buf, flags);
+ LIBVIRT_END_ALLOW_THREADS;
+
+ if (c_retval < 0)
+ goto cleanup;
+
+ py_retval = PyString_FromStringAndSize(buf, size);
+
+cleanup:
+ memset(buf, 0, size);
+ free(buf);
+ return py_retval;
+}
+
/************************************************************************
* *
* The registration stuff *
@@ -5112,6 +5185,8 @@ static PyMethodDef libvirtMethods[] = {
{(char *) "virDomainGetBlockIoTune", libvirt_virDomainGetBlockIoTune, METH_VARARGS, NULL},
{(char *) "virDomainSendKey", libvirt_virDomainSendKey, METH_VARARGS, NULL},
{(char *) "virDomainMigrateGetMaxSpeed", libvirt_virDomainMigrateGetMaxSpeed, METH_VARARGS, NULL},
+ {(char *) "virDomainBlockPeek", libvirt_virDomainBlockPeek, METH_VARARGS, NULL},
+ {(char *) "virDomainMemoryPeek", libvirt_virDomainMemoryPeek, METH_VARARGS, NULL},
{NULL, NULL, 0, NULL}
};
--
1.7.1
12 years, 11 months
[libvirt] [PATCH] rpc: retry to call dup() if fcntl with CLOEXEC fails
by dongsu.park@profitbricks.com
From: Dongsu Park <dongsu.park(a)profitbricks.com>
If fcntl with F_DUPFD_CLOEXEC fails, we need to try again to use dup()
to get the fd, instead of giving up right away.
Signed-off-by: Dongsu Park <dongsu.park(a)profitbricks.com>
Signed-off-by: Vasilis Liaskovitis <vasilis.liaskovitis(a)profitbricks.com>
---
src/rpc/virnetsocket.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index af4fc5e..25c7891 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -778,8 +778,15 @@ int virNetSocketDupFD(virNetSocketPtr sock, bool cloexec)
{
int fd;
- if (cloexec)
+ if (cloexec) {
fd = fcntl(sock->fd, F_DUPFD_CLOEXEC);
+ /* retry to use dup if fcntl fails */
+ if (fd < 0) {
+ virReportSystemError(errno, "%s",
+ _("fcntl failed, reverting to dup"));
+ fd = dup(sock->fd);
+ }
+ }
else
fd = dup(sock->fd);
if (fd < 0) {
--
1.7.7.2
12 years, 11 months
[libvirt] Fwd: [MacPorts] #32523: libvirt: update to 0.9.8
by Justin Clift
Hi all,
Just an FYI. Libvirt is now available through the Mac "MacPorts" package system, as well as HomeBrew.
Hope that's useful. :)
Regards and best wishes,
Justin Clift
Begin forwarded message:
> From: MacPorts <noreply(a)macports.org>
> Subject: Re: [MacPorts] #32523: libvirt: update to 0.9.8
> Date: 14 December 2011 3:39:10 PM AEDT
> To: ryandesign(a)macports.org, jclift(a)redhat.com
> Cc: macports-tickets(a)lists.macosforge.org
> Reply-To: macports-dev(a)lists.macosforge.org
>
> #32523: libvirt: update to 0.9.8
> --------------------------------------+-------------------------------------
> Reporter: ryandesign@… | Owner: jclift@…
> Type: defect | Status: closed
> Priority: Normal | Milestone:
> Component: ports | Version: 2.0.3
> Resolution: fixed | Keywords: haspatch
> Port: libvirt |
> --------------------------------------+-------------------------------------
> Changes (by ryandesign@…):
>
> * status: new => closed
> * resolution: => fixed
>
>
> Comment:
>
> r87956.
>
> --
> Ticket URL: <https://trac.macports.org/ticket/32523#comment:4>
> MacPorts <http://www.macports.org/>
> Ports system for Mac OS
--
Aeolus Community Manager
http://www.aeolusproject.org
12 years, 11 months
Re: [libvirt] libvirt support on QNX
by Chandrashekhar Jamadarkhani (cjamadar)
In which dir the source code for libvirt RPC client driver located to
port it to QNX ? Is it in libvirt-0.9.8/src/remote ?
Thanks,
Chandrashekhar
Hi Daniel,
Thanks Daniel for the info.
I was talking only about porting libvirt RPC client driver to QNX for
starting/monitoring VMs running on remote RHEL based host. Let me try
porting the libvirt RPC client driver to QNX.
Thanks,
Chandrashekhar
-----Original Message-----
From: Daniel P. Berrange [mailto:berrange redhat com]
Sent: Wednesday, November 16, 2011 4:07 PM
To: Chandrashekhar Jamadarkhani (cjamadar)
Cc: libvir-list redhat com
Subject: Re: [libvirt] libvirt support on QNX
On Wed, Nov 16, 2011 at 03:32:19PM +0530, Chandrashekhar Jamadarkhani
(cjamadar) wrote:
> Hi,
>
>
>
> I'm planning to use libvirt in a remote machine which is running on
QNX
> RTOS. Whether libvirt is ported to QNX, if not any problems in porting
> libvirt lib to QNX ?
AFAIK, no one has ever said they've tried libvirt on QNX. I presume you
are talking about the libvirt RPC client driver only, or are you
planning
to create some kind of hypervisor driver too ?
The libvirt RPC client driver is probably the most portable bit of our
code, only depending on a good sockets layer implementation & GNUTLS.
So if you pass flags to configure to disable all drivers, except for the
remote driver, you should be able to build it without undue trouble.
Regards,
Daniel
12 years, 11 months