[libvirt] [PATCH] qemu: snapshot: Don't mark all block disks for metadata reuse
by Peter Krempa
For block devices used as snapshot source the new snapshot code would
set the reuse flag. This inhibits to take snapshot without specially
preparing the block image before taking the snapshot.
Fortunately this is not a regression as only the new way of specifying
snapshot source is affected.
For the followin snapshot XML:
<domainsnapshot>
<disks>
<disk name='vda' type='block'>
<driver type='qcow2'/>
<source dev="/dev/andariel/testsnap" />
</disk>
</disks>
</domainsnapshot>
You'd get:
error: internal error: unable to execute QEMU command 'transaction': Image is not in qcow2 format
After this patch the snapshot is created successfully.
---
src/qemu/qemu_driver.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 7bf2020..7ac7aa2 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12885,13 +12885,11 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
switch ((virStorageType)snap->src->type) {
case VIR_STORAGE_TYPE_BLOCK:
- reuse = true;
- /* fallthrough */
case VIR_STORAGE_TYPE_FILE:
/* create the stub file and set selinux labels; manipulate disk in
* place, in a way that can be reverted on failure. */
- if (!reuse) {
+ if (!reuse && snap->src->type != VIR_STORAGE_TYPE_BLOCK) {
fd = qemuOpenFile(driver, vm, source, O_WRONLY | O_TRUNC | O_CREAT,
&need_unlink, NULL);
if (fd < 0)
--
1.9.3
10 years, 5 months
[libvirt] [PATCH v2 0/2] Expose PCI Express capabilities
by Michal Privoznik
diff to v1:
-Matin's review suggestions worked in
-I've found that (testing this on my new HW) that some PCI-Express devices
doesn't have to necessarily export link info. That's why I'm inventing this
virPCIDeviceHasPCIExpressLink() which tells us if that's the case. So for a PCI
Express device without link info exposed, the XML will simply contain
<pci-express/>.
Michal Privoznik (2):
virpci: Introduce virPCIDeviceIsPCIExpress and friends
nodedev: Introduce <pci-express/> to PCI devices
docs/formatnode.html.in | 19 +++
docs/schemas/nodedev.rng | 26 ++++
src/conf/node_device_conf.c | 138 ++++++++++++++++++++-
src/conf/node_device_conf.h | 33 ++++-
src/libvirt_private.syms | 3 +
src/node_device/node_device_udev.c | 34 +++++
src/util/virpci.c | 96 +++++++++++++-
src/util/virpci.h | 8 ++
.../pci_8086_0c0c_snd_hda_intel.xml | 16 +++
.../pci_8086_4238_pcie_wireless.xml | 26 ++++
tests/nodedevxml2xmltest.c | 2 +
11 files changed, 397 insertions(+), 4 deletions(-)
create mode 100644 tests/nodedevschemadata/pci_8086_0c0c_snd_hda_intel.xml
create mode 100644 tests/nodedevschemadata/pci_8086_4238_pcie_wireless.xml
--
1.8.5.5
10 years, 5 months
[libvirt] [PATCH] virsh: Parse "--mode readonly, shareable" in virsh attach-disk.
by Dongsheng Yang
We can not attach a disk with mode of both readonly and shareable.
Before:
# virsh attach-disk --domain jeos --source attach.img --target vdb --persistent --mode readonly --mode shareable
error: option --mode already seen
# virsh attach-disk --domain jeos --source attach.img --target vdb --persistent --mode readonly --shareable
error: option --mode already seen
# virsh attach-disk --domain jeos --source attach.img --target vdb --persistent --mode readonly,shareable
error: No support for readonly,shareable in command 'attach-disk'
After:
# virsh attach-disk --domain jeos --source attach.img --target vdb --persistent --mode readonly,shareable
Disk attached successfully
Signed-off-by: Dongsheng Yang <yangds.fnst(a)cn.fujitsu.com>
---
tools/virsh-domain.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 6b3dd70..62a9824 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -515,6 +515,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
bool config = vshCommandOptBool(cmd, "config");
bool live = vshCommandOptBool(cmd, "live");
bool persistent = vshCommandOptBool(cmd, "persistent");
+ char **modes = NULL, **tmp;
VSH_EXCLUSIVE_OPTIONS_VAR(persistent, current);
@@ -553,12 +554,9 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
- if (mode) {
- if (STRNEQ(mode, "readonly") && STRNEQ(mode, "shareable")) {
- vshError(ctl, _("No support for %s in command 'attach-disk'"),
- mode);
- goto cleanup;
- }
+ if (mode && !(modes = virStringSplit(mode, ",", 0))) {
+ vshError(ctl, "%s", _("Cannot parse mode string"));
+ goto cleanup;
}
if (wwn && !virValidateWWN(wwn))
@@ -591,8 +589,19 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
virBufferAsprintf(&buf, "<source %s='%s'/>\n",
isFile ? "file" : "dev", source);
virBufferAsprintf(&buf, "<target dev='%s'/>\n", target);
- if (mode)
- virBufferAsprintf(&buf, "<%s/>\n", mode);
+
+ tmp = modes;
+ while (tmp && *tmp) {
+ mode = *tmp;
+ if (STREQ(mode, "readonly") || STREQ(mode, "shareable")) {
+ virBufferAsprintf(&buf, "<%s/>\n", mode);
+ } else {
+ vshError(ctl, _("Unknown mode %s value, expecting "
+ "'readonly', 'shareable'"), mode);
+ goto cleanup;
+ }
+ tmp++;
+ }
if (serial)
virBufferAsprintf(&buf, "<serial>%s</serial>\n", serial);
--
1.8.3.1
10 years, 5 months
[libvirt] [PATCH] leaseshelper: fix another creash
by Pavel Hrdina
We create a 'lease_new' when we are adding new lease entry, then later
in the code we add the 'lease_new' into a 'leases_array_new' which
leades into the creash because we double free the 'lease_new'.
To prevent the double free we set the 'lease_new' to NULL after
successful append into the 'leases_array_new'.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/network/leaseshelper.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/network/leaseshelper.c b/src/network/leaseshelper.c
index 69081c3..bf1842b 100644
--- a/src/network/leaseshelper.c
+++ b/src/network/leaseshelper.c
@@ -331,6 +331,7 @@ main(int argc, char **argv)
_("failed to create json"));
goto cleanup;
}
+ lease_new = NULL;
}
if (!(leases_str = virJSONValueToString(leases_array_new, true))) {
--
1.8.5.5
10 years, 5 months
[libvirt] [libvirt-sandbox PATCH v2] Only set SELinux seclabel if supported by the host.
by Cédric Bosdonnat
This code depends on new API in libvirt-gconfig to extract the
secmodels handled by the host.
---
Diff to v1:
* Adapted the naming change from libvirt-gconfig
libvirt-sandbox/libvirt-sandbox-builder.c | 68 ++++++++++++++++++++-----------
1 file changed, 45 insertions(+), 23 deletions(-)
diff --git a/libvirt-sandbox/libvirt-sandbox-builder.c b/libvirt-sandbox/libvirt-sandbox-builder.c
index 48b3acc..327f144 100644
--- a/libvirt-sandbox/libvirt-sandbox-builder.c
+++ b/libvirt-sandbox/libvirt-sandbox-builder.c
@@ -323,38 +323,60 @@ static gboolean gvir_sandbox_builder_construct_devices(GVirSandboxBuilder *build
}
-static gboolean gvir_sandbox_builder_construct_security(GVirSandboxBuilder *builder G_GNUC_UNUSED,
+static gboolean gvir_sandbox_builder_construct_security(GVirSandboxBuilder *builder,
GVirSandboxConfig *config G_GNUC_UNUSED,
const gchar *statedir G_GNUC_UNUSED,
GVirConfigDomain *domain,
- GError **error G_GNUC_UNUSED)
+ GError **error)
{
GVirConfigDomainSeclabel *sec = gvir_config_domain_seclabel_new();
const char *label = gvir_sandbox_config_get_security_label(config);
+ GVirConnection *connection = gvir_sandbox_builder_get_connection(builder);
+ GVirConfigCapabilities *configCapabilities;
+ GVirConfigCapabilitiesHost *hostCapabilities;
+ GList *secmodels, *iter;
+ gboolean supportsSelinux = FALSE;
+
+ /* What security models are available on the host? */
+ if (!(configCapabilities = gvir_connection_get_capabilities(connection, error))) {
+ g_object_unref(sec);
+ return FALSE;
+ }
+
+ hostCapabilities = gvir_config_capabilities_get_host(configCapabilities);
- gvir_config_domain_seclabel_set_model(sec, "selinux");
- if (gvir_sandbox_config_get_security_dynamic(config)) {
- gvir_config_domain_seclabel_set_type(sec,
- GVIR_CONFIG_DOMAIN_SECLABEL_DYNAMIC);
- if (label)
- gvir_config_domain_seclabel_set_baselabel(sec, label);
- else if (gvir_config_domain_get_virt_type(domain) ==
- GVIR_CONFIG_DOMAIN_VIRT_LXC)
- gvir_config_domain_seclabel_set_baselabel(sec, "system_u:system_r:svirt_lxc_net_t:s0");
- else if (gvir_config_domain_get_virt_type(domain) ==
- GVIR_CONFIG_DOMAIN_VIRT_QEMU)
- gvir_config_domain_seclabel_set_baselabel(sec, "system_u:system_r:svirt_tcg_t:s0");
- else if (gvir_config_domain_get_virt_type(domain) ==
- GVIR_CONFIG_DOMAIN_VIRT_KVM)
- gvir_config_domain_seclabel_set_baselabel(sec, "system_u:system_r:svirt_t:s0");
- } else {
- gvir_config_domain_seclabel_set_type(sec,
- GVIR_CONFIG_DOMAIN_SECLABEL_STATIC);
- if (label)
- gvir_config_domain_seclabel_set_label(sec, label);
+ secmodels = gvir_config_capabilities_host_get_secmodels(hostCapabilities);
+ for (iter = secmodels; iter != NULL; iter = iter->next) {
+ supportsSelinux = g_str_equal(gvir_config_capabilities_host_secmodel_get_model(
+ GVIR_CONFIG_CAPABILITIES_HOST_SECMODEL(iter->data)), "selinux");
+ g_object_unref(iter->data);
}
- gvir_config_domain_set_seclabel(domain, sec);
+ if (supportsSelinux) {
+ gvir_config_domain_seclabel_set_model(sec, "selinux");
+ if (gvir_sandbox_config_get_security_dynamic(config)) {
+ gvir_config_domain_seclabel_set_type(sec,
+ GVIR_CONFIG_DOMAIN_SECLABEL_DYNAMIC);
+ if (label)
+ gvir_config_domain_seclabel_set_baselabel(sec, label);
+ else if (gvir_config_domain_get_virt_type(domain) ==
+ GVIR_CONFIG_DOMAIN_VIRT_LXC)
+ gvir_config_domain_seclabel_set_baselabel(sec, "system_u:system_r:svirt_lxc_net_t:s0");
+ else if (gvir_config_domain_get_virt_type(domain) ==
+ GVIR_CONFIG_DOMAIN_VIRT_QEMU)
+ gvir_config_domain_seclabel_set_baselabel(sec, "system_u:system_r:svirt_tcg_t:s0");
+ else if (gvir_config_domain_get_virt_type(domain) ==
+ GVIR_CONFIG_DOMAIN_VIRT_KVM)
+ gvir_config_domain_seclabel_set_baselabel(sec, "system_u:system_r:svirt_t:s0");
+ } else {
+ gvir_config_domain_seclabel_set_type(sec,
+ GVIR_CONFIG_DOMAIN_SECLABEL_STATIC);
+ if (label)
+ gvir_config_domain_seclabel_set_label(sec, label);
+ }
+
+ gvir_config_domain_set_seclabel(domain, sec);
+ }
g_object_unref(sec);
return TRUE;
--
1.8.4.5
10 years, 5 months
[libvirt] [PATCH 0/5] Expose host's huge pages capability
by Michal Privoznik
*** BLURB HERE ***
Michal Privoznik (5):
virnuma: Introduce huge pages helpers
virCaps: expose huge page info
Introduce virNodeGetFreePages
virsh: Expose virNodeGetFreePages
qemu: Implement virNodeGetFreePages
daemon/remote.c | 52 ++++++++++
docs/schemas/capability.rng | 21 ++++
include/libvirt/libvirt.h.in | 7 ++
src/conf/capabilities.c | 25 ++++-
src/conf/capabilities.h | 15 ++-
src/driver.h | 10 ++
src/libvirt.c | 95 +++++++++++++++++
src/libvirt_private.syms | 2 +
src/libvirt_public.syms | 4 +
src/libxl/libxl_conf.c | 1 +
src/nodeinfo.c | 41 +++++++-
src/qemu/qemu_capabilities.c | 29 +++++-
src/qemu/qemu_driver.c | 43 ++++++++
src/remote/remote_driver.c | 50 +++++++++
src/remote/remote_protocol.x | 20 +++-
src/remote_protocol-structs | 16 +++
src/test/test_driver.c | 2 +-
src/util/virnuma.c | 242 +++++++++++++++++++++++++++++++++++++++++++
src/util/virnuma.h | 10 ++
src/xen/xend_internal.c | 1 +
tests/vircaps2xmltest.c | 3 +-
tests/vircapstest.c | 1 +
tools/virsh-host.c | 167 +++++++++++++++++++++++++++++
tools/virsh.pod | 8 ++
24 files changed, 856 insertions(+), 9 deletions(-)
--
1.8.5.5
10 years, 5 months
[libvirt] [PATCH v3] QEMU: parse '-device vfio-pci' and '-device pci-assign'
by Olivia Yin
Signed-off-by: Olivia Yin <Hong-Hua.Yin(a)freescale.com>
Signed-off-by: Laine Stump <laine(a)laine.org>
Modify the existing function qemuParseCommandLinePCI(), which works with
-pcidevice, to support for "-device pci-assign" and "-device pci-assign".
Change test cases 'hostdev-vfio' and 'hostdev-pci-address-device' to
validate the new function.
The case related to QEMU_CAPS_HOST_PCI_MULTIDOMAIN which uses
'host=domain:bus:slot.func' is not supported yet.
---
src/qemu/qemu_command.c | 50 +++++++++++++++++++---
tests/qemuargv2xmltest.c | 3 +-
.../qemuxml2argv-hostdev-pci-address-device.xml | 6 +++
.../qemuxml2argvdata/qemuxml2argv-hostdev-vfio.xml | 1 +
4 files changed, 53 insertions(+), 7 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index e1d7e1b..3a4bc61 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -10193,7 +10193,8 @@ qemuParseCommandLineNet(virDomainXMLOptionPtr xmlopt,
* Tries to parse a QEMU PCI device
*/
static virDomainHostdevDefPtr
-qemuParseCommandLinePCI(const char *val)
+qemuParseCommandLinePCI(const char *val,
+ virDomainHostdevSubsysPCIBackendType backend)
{
int bus = 0, slot = 0, func = 0;
const char *start;
@@ -10222,10 +10223,20 @@ qemuParseCommandLinePCI(const char *val)
goto error;
}
start = end + 1;
- if (virStrToLong_i(start, NULL, 16, &func) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot extract PCI device function '%s'"), val);
- goto error;
+
+ if (backend) {
+ if (virStrToLong_i(start, &end, 16, &func) < 0 || *end != ',') {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot extract PCI device function '%s'"), val);
+ goto error;
+ } else
+ def->source.subsys.u.pci.backend = backend;
+ } else {
+ if (virStrToLong_i(start, NULL, 16, &func) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot extract PCI device function '%s'"), val);
+ goto error;
+ }
}
def->mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
@@ -11347,7 +11358,34 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
} else if (STREQ(arg, "-pcidevice")) {
virDomainHostdevDefPtr hostdev;
WANT_VALUE();
- if (!(hostdev = qemuParseCommandLinePCI(val)))
+ if (!(hostdev = qemuParseCommandLinePCI(val,
+ VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT)))
+ goto error;
+ if (VIR_APPEND_ELEMENT(def->hostdevs, def->nhostdevs, hostdev) < 0) {
+ virDomainHostdevDefFree(hostdev);
+ goto error;
+ }
+ } else if (STREQ(arg, "-device") && progargv[i+1] &&
+ STRPREFIX(progargv[i+1], "vfio-pci")) {
+ const char *start;
+ virDomainHostdevDefPtr hostdev;
+ WANT_VALUE();
+ start = val + strlen("vfio-pci,");
+ if (!(hostdev = qemuParseCommandLinePCI(start,
+ VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO)))
+ goto error;
+ if (VIR_APPEND_ELEMENT(def->hostdevs, def->nhostdevs, hostdev) < 0) {
+ virDomainHostdevDefFree(hostdev);
+ goto error;
+ }
+ } else if (STREQ(arg, "-device") && progargv[i+1] &&
+ STRPREFIX(progargv[i+1], "pci-assign")) {
+ const char *start;
+ virDomainHostdevDefPtr hostdev;
+ WANT_VALUE();
+ start = val + strlen("pci-assign,");
+ if (!(hostdev = qemuParseCommandLinePCI(start,
+ VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM)))
goto error;
if (VIR_APPEND_ELEMENT(def->hostdevs, def->nhostdevs, hostdev) < 0) {
virDomainHostdevDefFree(hostdev);
diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c
index 2cbbe3d..80188be 100644
--- a/tests/qemuargv2xmltest.c
+++ b/tests/qemuargv2xmltest.c
@@ -274,8 +274,9 @@ mymain(void)
DO_TEST("watchdog");
DO_TEST("hostdev-usb-address");
-
DO_TEST("hostdev-pci-address");
+ DO_TEST("hostdev-pci-address-device");
+ DO_TEST("hostdev-vfio");
DO_TEST("smp");
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address-device.xml b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address-device.xml
index b29ef58..b9a221a 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address-device.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address-device.xml
@@ -15,10 +15,16 @@
<devices>
<emulator>/usr/bin/qemu</emulator>
<disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
<source dev='/dev/HostVG/QEMUGuest2'/>
<target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
<hostdev mode='subsystem' type='pci' managed='yes'>
+ <driver name='kvm'/>
<source>
<address domain='0x0000' bus='0x06' slot='0x12' function='0x5'/>
</source>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio.xml b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio.xml
index 8daa53a..b99f798 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-vfio.xml
@@ -15,6 +15,7 @@
<devices>
<emulator>/usr/bin/qemu</emulator>
<disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
<source dev='/dev/HostVG/QEMUGuest2'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
--
1.8.5
10 years, 5 months
[libvirt] [PATCH] bhyve: silent destroy command errors on cleanup
by Roman Bogorodskiy
When virBhyveProcessStart() fails, it tries to unload
a guest that could have been already loaded using
bhyveload(8) to make sure not to leave it hanging in memory.
However, we could fail before loading a VM into memory,
so 'bhyvectl --destroy' command will fail and print
an error message that looks confusing to users.
So ignore errors when running this in cleanup.
---
src/bhyve/bhyve_process.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c
index b8db076..36c2c21 100644
--- a/src/bhyve/bhyve_process.c
+++ b/src/bhyve/bhyve_process.c
@@ -189,12 +189,13 @@ virBhyveProcessStart(virConnectPtr conn,
cleanup:
if (ret < 0) {
+ int exitstatus = -1;
virCommandPtr destroy_cmd;
if ((destroy_cmd = virBhyveProcessBuildDestroyCmd(driver,
vm->def)) != NULL) {
virCommandSetOutputFD(load_cmd, &logfd);
virCommandSetErrorFD(load_cmd, &logfd);
- ignore_value(virCommandRun(destroy_cmd, NULL));
+ ignore_value(virCommandRun(destroy_cmd, &exitstatus));
virCommandFree(destroy_cmd);
}
--
1.9.0
10 years, 5 months
[libvirt] [PATCH] storage: report VIR_ERR_NO_STORAGE_VOL when the file doesn't exist
by Giuseppe Scrivano
Report VIR_ERR_NO_STORAGE_VOL instead of a system error when lstat
fails because the file doesn't exist.
Fixes this problem in virt-install:
https://bugzilla.redhat.com/show_bug.cgi?id=1108922
Signed-off-by: Giuseppe Scrivano <gscrivan(a)redhat.com>
---
src/storage/storage_backend.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 380ca58..b38af52 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -1305,9 +1305,15 @@ virStorageBackendVolOpen(const char *path, struct stat *sb,
bool noerror = (flags & VIR_STORAGE_VOL_OPEN_NOERROR);
if (lstat(path, sb) < 0) {
- if (errno == ENOENT && noerror) {
- VIR_WARN("ignoring missing file '%s'", path);
- return -2;
+ if (errno == ENOENT) {
+ if (noerror) {
+ VIR_WARN("ignoring missing file '%s'", path);
+ return -2;
+ }
+ virReportError(VIR_ERR_NO_STORAGE_VOL,
+ _("no storage vol with matching path '%s'"),
+ path);
+ return -1;
}
virReportSystemError(errno,
_("cannot stat file '%s'"),
--
1.9.3
10 years, 5 months