[libvirt] QMP Capability Detection Issues with GIT version of QEMU
by Viktor Mihajlovski
I ran into trouble today trying to use the GIT level of QEMU.
In a nutshell: the capability detection with QMP is failing
and the fallback using -help isn't working with the GIT level
probably due to help text reformatting.
The failure reason is that QEMU cannot bind to the
QMP monitor socket in the /var/lib/libvirt/qemu directory.
That's because the child process is stripped of all
capabilities and this directory is chown'ed to qemu:qemu
by the QEMU driver.
Note that this is failing with the release QEMU as well,
with the difference that the fallback is working there.
I am willing to provide a patch, however I'd like
to get feedback on the approach to use:
1. Add back Linux capabilities CAP_DAC_OVERRIDE,
CAP_DAC_READ_SEARCH to allow QEMU to bind to
the monitor socket.
This seems to be hacky/dodging the problem.
2. Use a separate directory for the QMP probing
instance of QEMU.
3. Run the QMP QEMU under the configured qemu
user. This would be my favorite.
4. Other ideas?
--
Mit freundlichen Grüßen/Kind Regards
Viktor Mihajlovski
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
12 years
[libvirt] [PATCH] Correct include-password option for domdisplay
by Martin Kletzander
The 'virsh domdisplay' command is able to display the password
configured for spice, but it was missing for vnc type graphics.
This is just a simple patch for that to work properly.
---
tools/virsh-domain.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index cc47383..18aa869 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -7073,6 +7073,23 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
if (STREQ(scheme[iter], "vnc")) {
/* VNC protocol handlers take their port number as 'port' - 5900 */
port -= 5900;
+
+ if (vshCommandOptBool(cmd, "include-password")) {
+ /* Create our XPATH lookup for the SPICE password */
+ virAsprintf(&xpath,
+ "string(/domain/devices/graphics"
+ "[@type='%s']/@passwd)",
+ scheme[iter]);
+ if (!xpath) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ /* Attempt to get the SPICE password */
+ passwd = virXPathString(xpath, ctxt);
+ VIR_FREE(xpath);
+ }
+
} else if (STREQ(scheme[iter], "spice")) {
/* Create our XPATH lookup for the SPICE TLS Port */
virAsprintf(&xpath, "string(/domain/devices/graphics[@type='%s']"
--
1.8.0
12 years
[libvirt] FYI: Upgrade from pc-0.12 / pc-014 vs. savevm section "kvmclock"
by Philipp Hahn
Hello,
I'm using libvirt to manage my KVM instances. I created a VM with
qemu-kvm-0.12, later upgraded to qemu-kvm-0.14 and took a snapshot using
libvirt. As the original VM was created with qemu-kvm-0.12, libvirt
stored "pc-0.12" with its XML data. Now I upgraded to qemu-kvm-1.1.2, where
reverting to that snapshot fails with a the message
> Unknown savevm section or instance 'kvmclock' 0
> load of migration failed
I tracked that down to hw/pc_piix.c:590 where
> static QEMUMachine pc_machine_v0_12 = {
> .name = "pc-0.12",
> .desc = "Standard PC",
> .init = pc_init_pci_no_kvmclock,
is defined. If I change .init to pc_init_pci, I'm able to load the old
snapshot.
I think this is because kvm-0.14 always created the kvmclock device, while
that was only later changed (0ec329da) to be created "on demand" for pc-0.14s
onward. So the snapshot is no longer a pure pc-0.12, but some
pc-0.12+something, which qemu-kvm-1.1.2 refuses to load.
Now that I know what the problem is I just want to inform others, who might
experience the same problem. My workaround is a patched qemu-kvm, where I
changed that .init mentioned above, since an additional enabled kvmclock does
not seem to do any harm.
If someone has a better fix, I'm open to suggestions.
Sincerely
Philipp
--
Philipp Hahn Open Source Software Engineer hahn(a)univention.de
Univention GmbH be open. fon: +49 421 22 232- 0
Mary-Somerville-Str.1 D-28359 Bremen fax: +49 421 22 232-99
http://www.univention.de/
12 years
[libvirt] [PATCH] node_device: Fix the improper logic when enumerating SRIOV VF
by Osier Yang
pciGetVirtualFunctions returns 0 even if there is no "virtfn"
entry under the device sysfs path.
And pciGetVirtualFunctions returns -1 when it tries to get
the PCI config space of the VF, however, with keeping the
the VFs already detected.
That's why udevProcessPCI and gather_pci_cap use logic like:
if (!pciGetVirtualFunctions(syspath,
&data->pci_dev.virtual_functions,
&data->pci_dev.num_virtual_functions) ||
data->pci_dev.num_virtual_functions > 0)
data->pci_dev.flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION;
to tag the PCI device with "virtual_function" cap.
This results in a VF will aslo get "virtual_function" cap.
This patch fixes it by:
* Ignoring the VF which has failure of getting PCI config space
of the device (given that the succesfully detected VFs are kept
, it makes sense to not give up on the failure of one VF too)
with a warning, so pciGetVirtualFunctions will always return 0
except out of memory.
* Free the allocated *virtual_functions when out of memory
And thus the logic can be changed to:
/* Out of memory */
if (pciGetVirtualFunctions(syspath, &data->pci_dev.virtual_functions,
&data->pci_dev.num_virtual_functions) < 0)
goto out;
else if (!pciGetVirtualFunctions(syspath,
&data->pci_dev.virtual_functions,
&data->pci_dev.num_virtual_functions) &&
(data->pci_dev.num_virtual_functions > 0))
data->pci_dev.flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION;
This also fixes a memory leak in the old codes (it realloc the
*virtual_functions first, and doesn't shrink it when it fails on
getting the PCI config space).
---
src/node_device/node_device_hal.c | 13 +++++++++--
src/node_device/node_device_udev.c | 11 +++++++--
src/util/pci.c | 37 +++++++++++++++++++++++------------
3 files changed, 42 insertions(+), 19 deletions(-)
diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c
index ff73db0..69e6ebf 100644
--- a/src/node_device/node_device_hal.c
+++ b/src/node_device/node_device_hal.c
@@ -151,10 +151,17 @@ static int gather_pci_cap(LibHalContext *ctx, const char *udi,
if (!pciGetPhysicalFunction(sysfs_path, &d->pci_dev.physical_function))
d->pci_dev.flags |= VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION;
- if (!pciGetVirtualFunctions(sysfs_path, &d->pci_dev.virtual_functions,
- &d->pci_dev.num_virtual_functions) ||
- d->pci_dev.num_virtual_functions > 0)
+ if (!pciGetVirtualFunctions(sysfs_path,
+ &d->pci_dev.virtual_functions,
+ &d->pci_dev.num_virtual_functions) < 0) {
+ VIR_FREE(sysfs_path);
+ return -1;
+ } else if (!pciGetVirtualFunctions(sysfs_path,
+ &d->pci_dev.virtual_functions,
+ &d->pci_dev.num_virtual_functions) &&
+ (d->pci_dev.num_virtual_functions > 0))
d->pci_dev.flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION;
+ }
VIR_FREE(sysfs_path);
}
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index acd78f2..72b8850 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -484,9 +484,14 @@ static int udevProcessPCI(struct udev_device *device,
if (!pciGetPhysicalFunction(syspath, &data->pci_dev.physical_function))
data->pci_dev.flags |= VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION;
- if (!pciGetVirtualFunctions(syspath, &data->pci_dev.virtual_functions,
- &data->pci_dev.num_virtual_functions) ||
- data->pci_dev.num_virtual_functions > 0)
+ /* Out of memory */
+ if (pciGetVirtualFunctions(syspath, &data->pci_dev.virtual_functions,
+ &data->pci_dev.num_virtual_functions) < 0)
+ goto out;
+ else if (!pciGetVirtualFunctions(syspath,
+ &data->pci_dev.virtual_functions,
+ &data->pci_dev.num_virtual_functions) &&
+ (data->pci_dev.num_virtual_functions > 0))
data->pci_dev.flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION;
ret = 0;
diff --git a/src/util/pci.c b/src/util/pci.c
index d1ad121..3b4d96a 100644
--- a/src/util/pci.c
+++ b/src/util/pci.c
@@ -1930,6 +1930,7 @@ pciGetVirtualFunctions(const char *sysfs_path,
unsigned int *num_virtual_functions)
{
int ret = -1;
+ int i;
DIR *dir = NULL;
struct dirent *entry = NULL;
char *device_link = NULL;
@@ -1952,6 +1953,7 @@ pciGetVirtualFunctions(const char *sysfs_path,
*num_virtual_functions = 0;
while ((entry = readdir(dir))) {
if (STRPREFIX(entry->d_name, "virtfn")) {
+ struct pci_config_address *config_addr = NULL;
if (virBuildPath(&device_link, sysfs_path, entry->d_name) == -1) {
virReportOOMError();
@@ -1960,24 +1962,23 @@ pciGetVirtualFunctions(const char *sysfs_path,
VIR_DEBUG("Number of virtual functions: %d",
*num_virtual_functions);
- if (VIR_REALLOC_N(*virtual_functions,
- (*num_virtual_functions) + 1) != 0) {
- virReportOOMError();
- VIR_FREE(device_link);
- goto out;
- }
if (pciGetPciConfigAddressFromSysfsDeviceLink(device_link,
- &((*virtual_functions)[*num_virtual_functions])) !=
+ &config_addr) !=
SRIOV_FOUND) {
- /* We should not get back SRIOV_NOT_FOUND in this
- * case, so if we do, it's an error. */
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Failed to get SR IOV function from device "
- "link '%s'"), device_link);
+ VIR_WARN("Failed to get SRIOV function from device "
+ "link '%s'", device_link);
VIR_FREE(device_link);
- goto out;
+ continue;
} else {
+ if (VIR_ALLOC_N(*virtual_functions,
+ *num_virtual_functions + 1) < 0) {
+ virReportOOMError();
+ VIR_FREE(config_addr);
+ goto out;
+ }
+
+ (*virtual_functions)[*num_virtual_functions] = config_addr;
(*num_virtual_functions)++;
}
VIR_FREE(device_link);
@@ -1985,8 +1986,18 @@ pciGetVirtualFunctions(const char *sysfs_path,
}
ret = 0;
+ goto cleanup;
out:
+ if (*virtual_functions) {
+ for (i = 0; i < *num_virtual_functions; i++)
+ VIR_FREE((*virtual_functions)[i]);
+ VIR_FREE(*virtual_functions);
+ }
+
+cleanup:
+ if (device_link)
+ VIR_FREE(device_link);
if (dir)
closedir(dir);
--
1.7.7.6
12 years
[libvirt] [PATCH 0/3] IPv6 enhancements plus dnsmasq conf-file
by Gene Czarcinski
The three patches are submitted with "one" because there is a
dependency between them. That is, patch 2 (DHCPv6) assumes that
patch 1 (guest-to-guest IPV6) has been applied and patch 3
(dnsmasq conf-file) assumes that patch 2 has been applied. While
other files are also changed, most of the changes occur in
src/network/bridge_driver.c and result in the conflicts.
Yes, patch 1 was previously submitted as a stand-alone patch
but it became obvious that it was not really standalone.
This submittal is a "re-do" of my previous submittal which
involved similar changes. Specifically, the order of the
patches have been changed so that the conf-file changes are
after the DHCPv6 changes.
In addition, some code has been cleaned up. For example,
there is no need to modify the radvd configuration since
both DHCPv6 and dnsmasq's handling of RA are both keyed to
dnsmasq version 2.64 or later.
Gene Czarcinski (3):
v1: allow guest to guest IPv6 without gateway definition
v7.1 add support for DHCPv6
v7.2: put dnsmasq parameters into conf-file
docs/formatnetwork.html.in | 126 +++++-
src/conf/network_conf.c | 100 +++--
src/conf/network_conf.h | 1 +
src/network/bridge_driver.c | 461 +++++++++++++++------
src/network/bridge_driver.h | 7 +-
src/util/dnsmasq.c | 9 +-
tests/networkxml2argvdata/dhcp6-network.argv | 17 +
tests/networkxml2argvdata/dhcp6-network.xml | 16 +
tests/networkxml2argvdata/isolated-network.argv | 25 +-
tests/networkxml2argvdata/nat-network-dhcp6.argv | 20 +
tests/networkxml2argvdata/nat-network-dhcp6.xml | 26 ++
.../networkxml2argvdata/nat-network-dns-hosts.argv | 15 +-
.../nat-network-dns-srv-record-minimal.argv | 37 +-
.../nat-network-dns-srv-record.argv | 37 +-
.../nat-network-dns-txt-record.argv | 31 +-
tests/networkxml2argvdata/nat-network.argv | 29 +-
tests/networkxml2argvdata/netboot-network.argv | 29 +-
.../networkxml2argvdata/netboot-proxy-network.argv | 26 +-
.../routed-network-dhcphost.argv | 15 +
.../routed-network-dhcphost.xml | 19 +
tests/networkxml2argvdata/routed-network.argv | 13 +-
tests/networkxml2argvtest.c | 46 +-
22 files changed, 790 insertions(+), 315 deletions(-)
create mode 100644 tests/networkxml2argvdata/dhcp6-network.argv
create mode 100644 tests/networkxml2argvdata/dhcp6-network.xml
create mode 100644 tests/networkxml2argvdata/nat-network-dhcp6.argv
create mode 100644 tests/networkxml2argvdata/nat-network-dhcp6.xml
create mode 100644 tests/networkxml2argvdata/routed-network-dhcphost.argv
create mode 100644 tests/networkxml2argvdata/routed-network-dhcphost.xml
--
1.7.11.7
12 years
[libvirt] [PATCHv2] qemu: Stop recursive detection of image chains when an image is missing
by Peter Krempa
Commit e0c469e58b93f852a72265919703cb6abd3779f8 that fixes the detection
of image chain wasn't complete. Iteration through the backing image
chain has to stop at the last existing image if some of the images are
missing otherwise the backing chain that is cached contains entries with
paths being set to NULL resulting to:
error: Unable to allow access for disk path (null): Bad address
Fortunately stat() is kind enough not to crash when it's presented with
a NULL argument. At least on Linux.
---
Left meta->backingStoreRaw in place to mark broken chains, added a comment and a warning.
---
src/util/storage_file.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/util/storage_file.c b/src/util/storage_file.c
index 2249212..4417404 100644
--- a/src/util/storage_file.c
+++ b/src/util/storage_file.c
@@ -728,8 +728,13 @@ virStorageFileGetMetadataFromBuf(int format,
meta->backingStore = absolutePathFromBaseFile(path, backing);
if (meta->backingStore == NULL) {
/* the backing file is (currently) unavailable, treat this
- * file as standalone */
+ * file as standalone:
+ * backingStoreRaw is kept to mark broken image chains */
+ meta->backingStoreIsFile = false;
backingFormat = VIR_STORAGE_FILE_NONE;
+ VIR_WARN("Backing file '%s' of image '%s' is missing.",
+ meta->backingStoreRaw, path);
+
}
}
VIR_FREE(backing);
--
1.8.0
12 years
[libvirt] [PATCH] build: trivial fix error: implicit declaration of function 'malloc'
by Natanael Copa
Fixes this error when building with -Werror on Alpine Linux:
util/processinfo.c: In function 'virProcessInfoSetAffinity':
util/processinfo.c:52:5: error: implicit declaration of function 'malloc' [-Werror=implicit-function-declaration]
Signed-off-by: Natanael Copa <ncopa(a)alpinelinux.org>
---
src/util/processinfo.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/util/processinfo.c b/src/util/processinfo.c
index c3648d4..b8c60eb 100644
--- a/src/util/processinfo.c
+++ b/src/util/processinfo.c
@@ -21,6 +21,7 @@
#include <config.h>
+#include <stdlib.h>
#include <sched.h>
#include "processinfo.h"
--
1.8.0
12 years
[libvirt] RFC: Enable unprivileged SG_IO
by Osier Yang
Hi,
http://lwn.net/Articles/524720/ introduces new sysfs knob
(unpriv_sgio) for SCSI device to allow the unprivileged SG_IO.
I don't have solid thought on how the libvirt interface should
be yet. It shouldn't be a XML entry of disk device, as the device
can be shared by multiple guests, and the configuration should
be kept same for all of them, having a XML entry for it will
make things a mess.
What Paolo suggested is to add an entry in qemu.conf, just
like "cgroup_device_acl":
sgio_device_acl = [ "/dev/sda" ]
When libvirtd starting, set the sysfs knob "unpriv_sgio" of
the devices listed to 1, and 0 when libvirtd exists.
I don't quite agree with this approach, as entries in qemu.conf
generally should be configuration for the whole qemu driver,
however, the SG_IO setting is at the device layer, or not
higher than guest layer.
What I'm thinking about is to have a public API to tune the
knob independantly with domain/driver, that means it's up to
management apps to manage the knob's value, setting it to 1
before domain(s) starting, and 0 when no domain is using it.
Any thoughts?
Regards,
Osier
12 years
[libvirt] [PATCH v2] conf: Report sensible error for invalid disk name
by Martin Kletzander
The error "... but the cause is unknown" appeared for XMLs similar to
this:
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<source file='/dev/zero'/>
<target dev='sr0'/>
</disk>
Notice unsupported disk type (for the driver), but also no address
specified. The first part is not a problem and we should not abort
immediately because of that, but the combination with the address
unknown was causing an unspecified error.
While fixing this, I added an error to one place where this return
value was not managed properly.
---
v2:
- Error moved from virDiskNameToIndex(a)util/util.c to
virDomainDiskDefAssignAddress(a)conf/domain_conf.c
- One more error added into qemuParseCommandLine(a)qemu/qemu_command.c
src/conf/domain_conf.c | 6 +++++-
src/qemu/qemu_command.c | 6 +++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ed21f0f..3a1be02 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3063,8 +3063,12 @@ int
virDomainDiskDefAssignAddress(virCapsPtr caps, virDomainDiskDefPtr def)
{
int idx = virDiskNameToIndex(def->dst);
- if (idx < 0)
+ if (idx < 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("Unknown disk name '%s' and no address specified"),
+ def->dst);
return -1;
+ }
switch (def->bus) {
case VIR_DOMAIN_DISK_BUS_SCSI:
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 22bb209..097de9b 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8342,8 +8342,12 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps,
!disk->dst)
goto no_memory;
- if (virDomainDiskDefAssignAddress(caps, disk) < 0)
+ if (virDomainDiskDefAssignAddress(caps, disk) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Cannot assign address for device name '%s'"),
+ disk->dst);
goto error;
+ }
if (VIR_REALLOC_N(def->disks, def->ndisks+1) < 0)
goto no_memory;
--
1.8.0
12 years
[libvirt] [PATCH v3 UPDATED 0/2] Qemu/Gluster support in Libvirt
by Harsh Prateek Bora
Changelog:
v3 updated:
- Fix other network backends (nbd, rbd, sheepdog) to initialize new members
(transport, socket) of _virDomainDiskHostDef appropriately so that garbage
values doesnt break the argv2xml tests.
v3:
- RNG schema updated as required for unix transport [Paolo]
- introduced another new attribute 'socket' for unix transport [Paolo]
- Uses virURIFormat and virURIParse for URI parsing. [danpb]
- updated documentation as required. [Jirka]
v2:
- Addressed review comments by Jiri
- Updated patcheset as per new URI spec
Ref: http://lists.gnu.org/archive/html/qemu-devel/2012-09/msg05199.html
v1:
- Initial prototype
Harsh Prateek Bora (2):
Qemu/Gluster: Add Gluster protocol as supported network disk formats.
tests: Add tests for gluster protocol based network disks support
docs/formatdomain.html.in | 24 ++-
docs/schemas/domaincommon.rng | 35 ++++-
src/conf/domain_conf.c | 72 +++++++--
src/conf/domain_conf.h | 12 ++
src/libvirt_private.syms | 2 +
src/qemu/qemu_command.c | 168 ++++++++++++++++++++-
tests/qemuargv2xmltest.c | 1 +
.../qemuxml2argv-disk-drive-network-gluster.args | 1 +
.../qemuxml2argv-disk-drive-network-gluster.xml | 35 +++++
tests/qemuxml2argvtest.c | 2 +
10 files changed, 323 insertions(+), 29 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-gluster.xml
--
1.7.11.7
12 years