[libvirt] VNC Server in libvirt
by Jaime Loureiro Acuña
My name is Jaime Loureiro and I work in the Network & Applications area in
University of Vigo. I am writing to you hoping you can help me with some
libvirt graphics issues.
I was analysing the source code of the libvirt in order to find how to
access the display of each virtual machine. We are trying to generate a
video streaming from the graphics content, though it is not easy to find
what function is the most appropriate to do that. We tried to use the
screenshot feature, but the rate is to low to generate a smooth streaming.
I suposse the vnc server is reading the graphics output of each virtual
machine at a low level, however I cannot find the exact point where the
server is. Currently I am trying to understand the function
"virDomainOpenGraphics" in libvirt.c and, at a lower level, the function
"qemuProcessHandleGraphics" in qemu_process.c, but I 'm not sure if it is
possible to get what we need from them.
I would appreciate any help or clue you could provide regarding this issue.
Thank you very much in advance.
Best regards,
11 years, 7 months
[libvirt] [PATCH 0/2] Add version comparison method for virsh_version output
by John Ferlan
I believe this set of patches should be applied instead of those from
https://www.redhat.com/archives/libvirt-cim/2013-April/msg00006.html
I suppose we could consider combining the two functions; however, there
are a couple place where the return version string is compared more than
once, so I kept both interfaces.
The vxml change is just an informative message that showed me the name
of the image that was failing - I had created 'default-kvm-dimage.img'
and tests were failing to find 'default-kvm-dimage' to place into the
cimtest storage pool.
John Ferlan (2):
vxml: Add which volume could not be found to error message
Add and utilize virsh_version_cmp
.../08_CreateDiskResourcePool.py | 4 ++--
.../10_create_storagevolume.py | 6 ++++--
.../11_create_dir_storagevolume_errs.py | 5 +++--
.../12_create_netfs_storagevolume_errs.py | 5 +++--
.../13_delete_storagevolume.py | 5 +++--
.../14_delete_storagevolume_errs.py | 5 +++--
.../ResourcePoolConfigurationService/15_DiskPoolAutostart.py | 4 ++--
.../cimtest/SettingsDefineCapabilities/01_forward.py | 1 -
.../VirtualSystemManagementService/19_definenetwork_ers.py | 8 ++++----
suites/libvirt-cim/lib/XenKvmLib/common_util.py | 9 +++++----
suites/libvirt-cim/lib/XenKvmLib/pool.py | 6 +++---
suites/libvirt-cim/lib/XenKvmLib/rasd.py | 10 ++++++----
suites/libvirt-cim/lib/XenKvmLib/vxml.py | 4 ++--
suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py | 6 ++++++
14 files changed, 46 insertions(+), 32 deletions(-)
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCH 0/2] Fix domain list race crash
by Peter Krempa
This series fixes the race between freeing and accessing of domain objects and
provides a reproducer case to test it.
Peter Krempa (2):
conf: Fix race between looking up a domain object and freeing it
DO NOT APPLY UPSTREAM: Reproducer of domain free crash
src/conf/domain_conf.c | 8 ++++++++
src/qemu/qemu_driver.c | 6 ++++++
2 files changed, 14 insertions(+)
--
1.8.1.5
11 years, 7 months
[libvirt] [PATCH 00/12] A bunch of extensions to libxl driver
by Marek Marczykowski
This are some additional features to libxl driver. Some of them require change
in domain config structures/syntax. Details described with each patch.
The last two patches are bugfix for deadlock during daemon startup.
PS Please keep me in To/Cc - I'm not subscribed to the list.
Marek Marczykowski (12):
libxl: allow script for any network interface, not only bridge
libxl: PCI passthrough support
libxl: nodeDevice* support for PCI devices
libxl: populate xenstore memory entries at startup
conf: add 'script' attribute to disk specification
libxl: use disk 'script' attribute
conf: support backend domain name in disk and network devices
libxl: support backend domain setting for disk and net devices
libxl: fill HVM SDL and VNC settings based on <graphics/> entries
RFC: libxl: special 'stubdom-dm' emulator to use qemu in stub domain
conf: virDomainObjListRemoveLocked function
libxl: fix deadlock in libxlReconnectDomain
docs/schemas/domaincommon.rng | 14 ++
src/conf/domain_conf.c | 54 ++++++++
src/conf/domain_conf.h | 5 +
src/libvirt_private.syms | 1 +
src/libxl/libxl_conf.c | 297 +++++++++++++++++++++++++++++++++---------
src/libxl/libxl_conf.h | 6 +-
src/libxl/libxl_driver.c | 253 +++++++++++++++++++++++++++++++----
7 files changed, 545 insertions(+), 85 deletions(-)
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCH 03/12] libxl: nodeDevice* support for PCI devices
by Marek Marczykowski
For now only for PCI devices. Mostly copy-paste from old xen driver.
---
src/libxl/libxl_driver.c | 193 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 193 insertions(+)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 40a7a6b..011edf8 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -42,6 +42,7 @@
#include "libxl.h"
#include "libxl_driver.h"
#include "libxl_conf.h"
+#include "node_device_conf.h"
#include "xen_xm.h"
#include "virtypedparam.h"
#include "viruri.h"
@@ -3666,6 +3667,195 @@ libxlDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml,
return libxlDomainModifyDeviceFlags(dom, xml, flags, LIBXL_DEVICE_UPDATE);
}
+static int
+libxlNodeDeviceGetPciInfo(virNodeDevicePtr dev,
+ unsigned *domain,
+ unsigned *bus,
+ unsigned *slot,
+ unsigned *function)
+{
+ virNodeDeviceDefPtr def = NULL;
+ virNodeDevCapsDefPtr cap;
+ char *xml = NULL;
+ int ret = -1;
+
+ xml = virNodeDeviceGetXMLDesc(dev, 0);
+ if (!xml)
+ goto out;
+
+ def = virNodeDeviceDefParseString(xml, EXISTING_DEVICE, NULL);
+ if (!def)
+ goto out;
+
+ cap = def->caps;
+ while (cap) {
+ if (cap->type == VIR_NODE_DEV_CAP_PCI_DEV) {
+ *domain = cap->data.pci_dev.domain;
+ *bus = cap->data.pci_dev.bus;
+ *slot = cap->data.pci_dev.slot;
+ *function = cap->data.pci_dev.function;
+ break;
+ }
+
+ cap = cap->next;
+ }
+
+ if (!cap) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("device %s is not a PCI device"), dev->name);
+ goto out;
+ }
+
+ ret = 0;
+out:
+ virNodeDeviceDefFree(def);
+ VIR_FREE(xml);
+ return ret;
+}
+
+static int
+libxlNodeDeviceDettach(virNodeDevicePtr dev)
+{
+ virPCIDevicePtr pci;
+ unsigned domain, bus, slot, function;
+ int ret = -1;
+
+ if (libxlNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
+ return -1;
+
+ pci = virPCIDeviceNew(domain, bus, slot, function);
+ if (!pci)
+ return -1;
+
+ if (virPCIDeviceDetach(pci, NULL, NULL, "pciback") < 0)
+ goto out;
+
+ ret = 0;
+out:
+ virPCIDeviceFree(pci);
+ return ret;
+}
+
+static int
+libxlNodeDeviceAssignedDomainId(virNodeDevicePtr dev)
+{
+ int numdomains;
+ int numpcidevs;
+ int ret = -1, i, j;
+ int *ids = NULL;
+ char *bdf = NULL;
+ char *xref = NULL;
+ unsigned int domain, bus, slot, function;
+ libxl_device_pci *pcidevs = NULL;
+ virConnectPtr conn = dev->conn;
+ libxlDriverPrivatePtr driver = conn->privateData;
+
+ /* Get active domains */
+ numdomains = libxlNumDomains(conn);
+ if (numdomains < 0) {
+ return ret;
+ }
+ if (numdomains > 0){
+ if (VIR_ALLOC_N(ids, numdomains) < 0) {
+ virReportOOMError();
+ goto out;
+ }
+ if ((numdomains = libxlListDomains(conn, &ids[0], numdomains)) < 0) {
+ goto out;
+ }
+ }
+
+ /* Get pci bdf */
+ if (libxlNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
+ goto out;
+
+ if (virAsprintf(&bdf, "%04x:%02x:%02x.%0x",
+ domain, bus, slot, function) < 0) {
+ virReportOOMError();
+ goto out;
+ }
+
+ libxlDriverLock(driver);
+ /* Check if bdf is assigned to one of active domains */
+ for (i = 0; i < numdomains; i++) {
+ pcidevs = libxl_device_pci_list(driver->ctx, ids[i], &numpcidevs);
+ if (pcidevs == NULL) {
+ continue;
+ } else {
+ for (j = 0; j < numpcidevs; j++) {
+ if (pcidevs[j].bus == bus && pcidevs[j].dev == slot && pcidevs[j].func == function) {
+ ret = ids[i];
+ break;
+ }
+ }
+ VIR_FREE(pcidevs);
+ }
+ }
+ libxlDriverUnlock(driver);
+
+ VIR_FREE(xref);
+ VIR_FREE(bdf);
+out:
+ VIR_FREE(ids);
+
+ return ret;
+}
+
+static int
+libxlNodeDeviceReAttach(virNodeDevicePtr dev)
+{
+ virPCIDevicePtr pci;
+ unsigned domain, bus, slot, function;
+ int ret = -1;
+ int domid;
+
+ if (libxlNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
+ return -1;
+
+ pci = virPCIDeviceNew(domain, bus, slot, function);
+ if (!pci)
+ return -1;
+
+ /* Check if device is assigned to an active guest */
+ if ((domid = libxlNodeDeviceAssignedDomainId(dev)) >= 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Device %s has been assigned to guest %d"),
+ dev->name, domid);
+ goto out;
+ }
+
+ if (virPCIDeviceReattach(pci, NULL, NULL, "pciback") < 0)
+ goto out;
+
+ ret = 0;
+out:
+ virPCIDeviceFree(pci);
+ return ret;
+}
+
+static int
+libxlNodeDeviceReset(virNodeDevicePtr dev)
+{
+ virPCIDevicePtr pci;
+ unsigned domain, bus, slot, function;
+ int ret = -1;
+
+ if (libxlNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
+ return -1;
+
+ pci = virPCIDeviceNew(domain, bus, slot, function);
+ if (!pci)
+ return -1;
+
+ if (virPCIDeviceReset(pci, NULL, NULL) < 0)
+ goto out;
+
+ ret = 0;
+out:
+ virPCIDeviceFree(pci);
+ return ret;
+}
+
static unsigned long long
libxlNodeGetFreeMemory(virConnectPtr conn)
{
@@ -4233,6 +4423,9 @@ static virDriver libxlDriver = {
.nodeGetFreeMemory = libxlNodeGetFreeMemory, /* 0.9.0 */
.domainEventRegister = libxlDomainEventRegister, /* 0.9.0 */
.domainEventDeregister = libxlDomainEventDeregister, /* 0.9.0 */
+ .nodeDeviceDettach = libxlNodeDeviceDettach, /* 1.0.4 */
+ .nodeDeviceReAttach = libxlNodeDeviceReAttach, /* 1.0.4 */
+ .nodeDeviceReset = libxlNodeDeviceReset, /* 1.0.4 */
.domainManagedSave = libxlDomainManagedSave, /* 0.9.2 */
.domainHasManagedSaveImage = libxlDomainHasManagedSaveImage, /* 0.9.2 */
.domainManagedSaveRemove = libxlDomainManagedSaveRemove, /* 0.9.2 */
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCH 04/12] libxl: populate xenstore memory entries at startup
by Marek Marczykowski
libxl uses some xenstore entries for hints in memory management
(especially when starting new domain). This includes dom0 memory limit
and Xen free memory margin, based on current system state. Entries are
created at first usage, so force such usage at daemon startup, which most
likely will be before any domain startup.
---
src/libxl/libxl_driver.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 011edf8..89546a5 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -1115,6 +1115,7 @@ libxlStartup(bool privileged,
char *log_file = NULL;
virCommandPtr cmd;
int status, ret = 0;
+ unsigned int free_mem;
char ebuf[1024];
/* Disable libxl driver if non-root */
@@ -1240,6 +1241,13 @@ libxlStartup(bool privileged,
goto error;
}
+ /* This will fill xenstore info about free and dom0 memory - if missing,
+ * should be called before starting first domain */
+ if (libxl_get_free_memory(libxl_driver->ctx, &free_mem)) {
+ VIR_ERROR(_("cannot get free memory info"));
+ goto error;
+ }
+
if (!(libxl_driver->xmlconf = virDomainXMLConfNew(&libxlDomainXMLPrivateDataCallbacks,
NULL)))
goto error;
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCH 02/12] libxl: PCI passthrough support
by Marek Marczykowski
---
src/libxl/libxl_conf.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/libxl/libxl_conf.h | 2 ++
2 files changed, 74 insertions(+)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index ffc7bbb..7668305 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -759,6 +759,74 @@ error:
return -1;
}
+int
+libxlMakePci(virDomainHostdevDefPtr l_hostdev,
+ libxl_device_pci *x_pci)
+{
+ if (l_hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("This driver supports only subsystem host device mode (PCI devices only)"));
+ return -1;
+ }
+ if (l_hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("This driver supports only PCI host devices"));
+ return -1;
+ }
+
+ x_pci->bus = l_hostdev->source.subsys.u.pci.bus;
+ x_pci->dev = l_hostdev->source.subsys.u.pci.slot;
+ x_pci->func = l_hostdev->source.subsys.u.pci.function;
+ return 0;
+}
+
+static int
+libxlMakePciList(virDomainDefPtr def,
+ libxl_domain_config *d_config)
+{
+ virDomainHostdevDefPtr *l_hostdevs = def->hostdevs;
+ int nhostdevs = def->nhostdevs;
+ int npcidevs = 0;
+ libxl_device_pci *x_pcidevs;
+ int i, j;
+
+ if (nhostdevs == 0)
+ return 0;
+
+ /* count PCI devices, ignore others (USB) */
+ for (i = 0; i < nhostdevs; i++) {
+ if (l_hostdevs[i]->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+ l_hostdevs[i]->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
+ npcidevs++;
+ }
+ if (VIR_ALLOC_N(x_pcidevs, npcidevs) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+
+ for (i = 0, j = 0; i < nhostdevs; i++) {
+ if (l_hostdevs[i]->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
+ l_hostdevs[i]->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
+ continue;
+
+ libxl_device_pci_init(&x_pcidevs[j]);
+
+ if (libxlMakePci(l_hostdevs[i], &x_pcidevs[j]) < 0)
+ goto error;
+ j++;
+ }
+
+ d_config->pcidevs = x_pcidevs;
+ d_config->num_pcidevs = npcidevs;
+
+ return 0;
+
+error:
+ for (i = 0; i < npcidevs; i++) {
+ libxl_device_pci_dispose(&x_pcidevs[i]);
+ }
+ VIR_FREE(x_pcidevs);
+ return -1;
+}
+
virCapsPtr
libxlMakeCapabilities(libxl_ctx *ctx)
{
@@ -817,6 +885,10 @@ libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
goto error;
}
+ if (libxlMakePciList(def, d_config) < 0) {
+ goto error;
+ }
+
d_config->on_reboot = def->onReboot;
d_config->on_poweroff = def->onPoweroff;
d_config->on_crash = def->onCrash;
diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
index f8602b4..b3ab3bf 100644
--- a/src/libxl/libxl_conf.h
+++ b/src/libxl/libxl_conf.h
@@ -119,6 +119,8 @@ libxlMakeNic(virDomainNetDefPtr l_nic, libxl_device_nic *x_nic);
int
libxlMakeVfb(libxlDriverPrivatePtr driver,
virDomainGraphicsDefPtr l_vfb, libxl_device_vfb *x_vfb);
+int
+libxlMakePci(virDomainHostdevDefPtr l_hostdev, libxl_device_pci *x_pci);
int
libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCH 01/12] libxl: allow script for any network interface, not only bridge
by Marek Marczykowski
This can be useful for route or NAT networks, or any other custom
network setup. Especially configuration example in documentation uses
<script/> tag with type 'ethernet'.
---
src/libxl/libxl_conf.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index b208dd8..ffc7bbb 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -608,18 +608,11 @@ libxlMakeNic(virDomainNetDefPtr l_nic, libxl_device_nic *x_nic)
virReportOOMError();
return -1;
}
- if (l_nic->script &&
- (x_nic->script = strdup(l_nic->script)) == NULL) {
- virReportOOMError();
- return -1;
- }
- } else {
- if (l_nic->script) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("scripts are not supported on interfaces of type %s"),
- virDomainNetTypeToString(l_nic->type));
- return -1;
- }
+ }
+ if (l_nic->script &&
+ (x_nic->script = strdup(l_nic->script)) == NULL) {
+ virReportOOMError();
+ return -1;
}
return 0;
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCH 06/12] libxl: use disk 'script' attribute
by Marek Marczykowski
Implement handling of previously introduced <script/> element for disk config.
This can be used for custom backend configuration like non-standard
device-mapper nodes, or to prepare device in other domain (see the next patch).
---
src/libxl/libxl_conf.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 7668305..4bd62e9 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -484,6 +484,11 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk)
return -1;
}
+ if (l_disk->script && (x_disk->script = strdup(l_disk->script)) == NULL) {
+ virReportOOMError();
+ return -1;
+ }
+
if (l_disk->driverName) {
if (STREQ(l_disk->driverName, "tap") ||
STREQ(l_disk->driverName, "tap2")) {
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCH 05/12] conf: add 'script' attribute to disk specification
by Marek Marczykowski
Script to be called to prepare custom device for domain. Done with Xen
in mind, it maps to libxl_device_disk.script.
XML configuration would be:
<disk type='block' device='disk'>
<source dev='/dev/mapper/custom-device'/>
<script path='/script/to/setup/custom-device'/>
<target dev='xvdc'/>
</disk>
---
src/conf/domain_conf.c | 10 ++++++++++
src/conf/domain_conf.h | 1 +
2 files changed, 11 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f3fca7f..257a265 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1102,6 +1102,7 @@ void virDomainDiskDefFree(virDomainDiskDefPtr def)
VIR_FREE(def->wwn);
VIR_FREE(def->vendor);
VIR_FREE(def->product);
+ VIR_FREE(def->script);
if (def->auth.secretType == VIR_DOMAIN_DISK_SECRET_TYPE_USAGE)
VIR_FREE(def->auth.secret.usage);
virStorageEncryptionFree(def->encryption);
@@ -3993,6 +3994,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
char *wwn = NULL;
char *vendor = NULL;
char *product = NULL;
+ char *script = NULL;
int expected_secret_usage = -1;
int auth_secret_usage = -1;
@@ -4148,6 +4150,9 @@ virDomainDiskDefParseXML(virCapsPtr caps,
if (target &&
STRPREFIX(target, "ioemu:"))
memmove(target, target+6, strlen(target)-5);
+ } else if (!script &&
+ xmlStrEqual(cur->name, BAD_CAST "script")) {
+ script = virXMLPropString(cur, "path");
} else if (xmlStrEqual(cur->name, BAD_CAST "geometry")) {
if (virXPathUInt("string(./geometry/@cyls)",
ctxt, &def->geometry.cylinders) < 0) {
@@ -4690,6 +4695,8 @@ virDomainDiskDefParseXML(virCapsPtr caps,
source = NULL;
def->dst = target;
target = NULL;
+ def->script = script;
+ script = NULL;
def->hosts = hosts;
hosts = NULL;
def->nhosts = nhosts;
@@ -4788,6 +4795,7 @@ cleanup:
VIR_FREE(wwn);
VIR_FREE(vendor);
VIR_FREE(product);
+ VIR_FREE(script);
ctxt->node = save_ctxt;
return def;
@@ -12899,6 +12907,8 @@ virDomainDiskDefFormat(virBufferPtr buf,
}
}
+ virBufferEscapeString(buf, " <script path='%s'/>\n", def->script);
+
virDomainDiskGeometryDefFormat(buf, def);
virDomainDiskBlockIoDefFormat(buf, def);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index edddf25..d55d209 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -668,6 +668,7 @@ struct _virDomainDiskDef {
bool rawio_specified;
int rawio; /* no = 0, yes = 1 */
int sgio; /* enum virDomainDiskSGIO */
+ char *script;
size_t nseclabels;
virSecurityDeviceLabelDefPtr *seclabels;
--
1.8.1.4
11 years, 7 months