[libvirt] [PATCH v2] qemu: Fix using guest architecture as lookup key
by Andrea Bolognani
When looking for a QEMU binary suitable for running ppc64le guests
we have to take into account the fact that we use the QEMU target
as key for the hash, so direct comparison is not good enough.
Factor out the logic from virQEMUCapsFindBinaryForArch() to a new
virQEMUCapsFindTarget() function and use that both when looking
for QEMU binaries available on the system and when looking up
QEMU capabilities later.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1260753
---
src/qemu/qemu_capabilities.c | 100 ++++++++++++++++++++++++++++---------------
1 file changed, 65 insertions(+), 35 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 4ad1bdb..6757907 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -386,6 +386,28 @@ static const char *virQEMUCapsArchToString(virArch arch)
return virArchToString(arch);
}
+/* Given a host and guest architectures, find a suitable QEMU target.
+ *
+ * This is meant to be used as a second attempt if qemu-system-$guestarch
+ * can't be found, eg. on a x86_64 host you want to use qemu-system-i386,
+ * if available, instead of qemu-system-x86_64 to run i686 guests */
+static virArch
+virQEMUCapsFindTarget(virArch hostarch,
+ virArch guestarch)
+{
+ /* Both ppc64 and ppc64le guests can use the ppc64 target */
+ if (ARCH_IS_PPC64(guestarch))
+ guestarch = VIR_ARCH_PPC64;
+
+ /* armv7l guests on aarch64 hosts can use the aarch64 target
+ * i686 guests on x86_64 hosts can use the x86_64 target */
+ if ((guestarch == VIR_ARCH_ARMV7L && hostarch == VIR_ARCH_AARCH64) ||
+ (guestarch == VIR_ARCH_I686 && hostarch == VIR_ARCH_X86_64)) {
+ return hostarch;
+ }
+
+ return guestarch;
+}
static virCommandPtr
virQEMUCapsProbeCommand(const char *qemu,
@@ -690,51 +712,52 @@ virQEMUCapsProbeCPUModels(virQEMUCapsPtr qemuCaps, uid_t runUid, gid_t runGid)
return ret;
}
-
static char *
-virQEMUCapsFindBinaryForArch(virArch hostarch,
- virArch guestarch)
+virQEMUCapsFindBinary(const char *format,
+ const char *archstr)
{
- char *ret;
- const char *archstr;
- char *binary;
-
- if (ARCH_IS_PPC64(guestarch))
- archstr = virQEMUCapsArchToString(VIR_ARCH_PPC64);
- else
- archstr = virQEMUCapsArchToString(guestarch);
+ char *ret = NULL;
+ char *binary = NULL;
- if (virAsprintf(&binary, "qemu-system-%s", archstr) < 0)
- return NULL;
+ if (virAsprintf(&binary, format, archstr) < 0)
+ goto out;
ret = virFindFileInPath(binary);
VIR_FREE(binary);
- if (ret && !virFileIsExecutable(ret))
- VIR_FREE(ret);
+ if (ret && virFileIsExecutable(ret))
+ goto out;
- if (guestarch == VIR_ARCH_ARMV7L &&
- !ret &&
- hostarch == VIR_ARCH_AARCH64) {
- ret = virFindFileInPath("qemu-system-aarch64");
- if (ret && !virFileIsExecutable(ret))
- VIR_FREE(ret);
- }
+ VIR_FREE(ret);
- if (guestarch == VIR_ARCH_I686 &&
- !ret &&
- hostarch == VIR_ARCH_X86_64) {
- ret = virFindFileInPath("qemu-system-x86_64");
- if (ret && !virFileIsExecutable(ret))
- VIR_FREE(ret);
- }
+ out:
+ return ret;
+}
+
+static char *
+virQEMUCapsFindBinaryForArch(virArch hostarch,
+ virArch guestarch)
+{
+ char *ret = NULL;
+ const char *archstr;
+
+ /* First attempt: try the guest architecture as it is */
+ archstr = virQEMUCapsArchToString(guestarch);
+ if ((ret = virQEMUCapsFindBinary("qemu-system-%s", archstr)) != NULL)
+ goto out;
- if (guestarch == VIR_ARCH_I686 &&
- !ret) {
- ret = virFindFileInPath("qemu");
- if (ret && !virFileIsExecutable(ret))
- VIR_FREE(ret);
+ /* Second attempt: use some arch-specific rules */
+ archstr = virQEMUCapsArchToString(virQEMUCapsFindTarget(hostarch,
+ guestarch));
+ if ((ret = virQEMUCapsFindBinary("qemu-system-%s", archstr)) != NULL)
+ goto out;
+
+ /* Third attempt, i686 only: try 'qemu' */
+ if (guestarch == VIR_ARCH_I686) {
+ if ((ret = virQEMUCapsFindBinary("%s", "qemu")) != NULL)
+ goto out;
}
+ out:
return ret;
}
@@ -3793,10 +3816,17 @@ virQEMUCapsCacheLookupByArch(virQEMUCapsCachePtr cache,
virMutexLock(&cache->lock);
ret = virHashSearch(cache->binaries, virQEMUCapsCompareArch, &data);
- VIR_DEBUG("Returning caps %p for arch %s", ret, virArchToString(arch));
+ if (!ret) {
+ /* If the first attempt at findind capabilities has failed, try
+ * again using the QEMU target as lookup key instead */
+ data.arch = virQEMUCapsFindTarget(virArchFromHost(), data.arch);
+ ret = virHashSearch(cache->binaries, virQEMUCapsCompareArch, &data);
+ }
virObjectRef(ret);
virMutexUnlock(&cache->lock);
+ VIR_DEBUG("Returning caps %p for arch %s", ret, virArchToString(arch));
+
return ret;
}
--
2.4.3
9 years, 2 months
[libvirt] [PATCH] libxl: fix compiler error introduced by commit ba25c214
by Jim Fehlig
libxl/libxl_conf.c: In function 'libxlDriverConfigNew':
libxl/libxl_conf.c:1560:30: error: 'log_level' may be used uninitialized
in this function [-Werror=maybe-uninitialized]
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
Pushing under the build-breaker rule.
src/libxl/libxl_conf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 40fa4b5..35fd495 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -1496,7 +1496,7 @@ libxlDriverConfigNew(void)
{
libxlDriverConfigPtr cfg;
char *log_file = NULL;
- xentoollog_level log_level;
+ xentoollog_level log_level = XTL_DEBUG;
char ebuf[1024];
unsigned int free_mem;
--
2.5.0
9 years, 2 months
[libvirt] [PATCH] qemu: The ppc64 target can run both ppc64 and ppc64le guests
by Andrea Bolognani
When looking for a QEMU binary suitable for running ppc64le guests
we have to take into account the fact that we use the QEMU target
as key for the hash, so direct comparison is not good enough:
normalize everything that can run on the ppc64 target to
VIR_ARCH_PPC64 instead.
This approach was already used in virQEMUCapsFindBinaryForArch(),
and I've added a comment there to clarify why it's needed.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1260753
---
src/qemu/qemu_capabilities.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 4ad1bdb..a06141e 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -699,6 +699,7 @@ virQEMUCapsFindBinaryForArch(virArch hostarch,
const char *archstr;
char *binary;
+ /* qemu-system-ppc64 can run both ppc64 and ppc64le guests */
if (ARCH_IS_PPC64(guestarch))
archstr = virQEMUCapsArchToString(VIR_ARCH_PPC64);
else
@@ -3791,6 +3792,10 @@ virQEMUCapsCacheLookupByArch(virQEMUCapsCachePtr cache,
virQEMUCapsPtr ret = NULL;
struct virQEMUCapsSearchData data = { .arch = arch };
+ /* QEMU's ppc64 target can run both ppc64 and ppc64le guests */
+ if (ARCH_IS_PPC64(data.arch))
+ data.arch = VIR_ARCH_PPC64;
+
virMutexLock(&cache->lock);
ret = virHashSearch(cache->binaries, virQEMUCapsCompareArch, &data);
VIR_DEBUG("Returning caps %p for arch %s", ret, virArchToString(arch));
--
2.4.3
9 years, 2 months
[libvirt] [PATCH v3] Ignore virtio-mmio disks in qemuAssignDevicePCISlots()
by Pavel Fedin
Fixes the following error when attempting to add a disk with bus='virtio'
to a machine which actually supports virtio-mmio (caught with ARM virt):
virtio disk cannot have an address of type 'virtio-mmio'
The problem has been likely introduced by
e8d55172544c1fafe31a9e09346bdebca4f0d6f9. Before that
qemuAssignDevicePCISlots() was never called for ARM "virt" machine.
Signed-off-by: Pavel Fedin <p.fedin(a)samsung.com>
---
v2 => v3
- Bring back qemuCaps to qemuAssignDevicePCISlots(), was lost in
a3ecd63e928ff39d73c1c14b0fb3be8addbc977b
- Swap conditions so as not to call virQEMUCapsGet() every time
v1 => v2
- Added check for QEMU_CAPS_DEVICE_VIRTIO_MMIO, this leaves the
error message for machines which actually do not support
virtio-mmio. In this case the user may still attempt to add
such a disk manually.
---
src/qemu/qemu_command.c | 11 +++++++++--
src/qemu/qemu_command.h | 1 +
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index ec5e3d4..ea1bb28 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2241,7 +2241,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
virDomainPCIAddressReserveNextSlot(addrs, &info, flags) < 0)
goto cleanup;
- if (qemuAssignDevicePCISlots(def, addrs) < 0)
+ if (qemuAssignDevicePCISlots(def, qemuCaps, addrs) < 0)
goto cleanup;
for (i = 1; i < addrs->nbuses; i++) {
@@ -2274,7 +2274,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
if (qemuValidateDevicePCISlotsChipsets(def, qemuCaps, addrs) < 0)
goto cleanup;
- if (qemuAssignDevicePCISlots(def, addrs) < 0)
+ if (qemuAssignDevicePCISlots(def, qemuCaps, addrs) < 0)
goto cleanup;
for (i = 0; i < def->ncontrollers; i++) {
@@ -2406,6 +2406,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
*/
int
qemuAssignDevicePCISlots(virDomainDefPtr def,
+ virQEMUCapsPtr qemuCaps,
virDomainPCIAddressSetPtr addrs)
{
size_t i, j;
@@ -2598,6 +2599,12 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)
continue;
+ /* Also ignore virtio-mmio disks if our machine allows them */
+ if (def->disks[i]->info.type ==
+ VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MMIO))
+ continue;
+
if (def->disks[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("virtio disk cannot have an address of type '%s'"),
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 767d31f..4aa7f2d 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -284,6 +284,7 @@ virDomainPCIAddressSetPtr qemuDomainPCIAddressSetCreate(virDomainDefPtr def,
bool dryRun);
int qemuAssignDevicePCISlots(virDomainDefPtr def,
+ virQEMUCapsPtr qemuCaps,
virDomainPCIAddressSetPtr addrs);
int qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps);
--
1.9.5.msysgit.0
9 years, 2 months
[libvirt] [PATCH 0/3] Implement mockup capabilities cache in QEMU tests
by Pavel Fedin
Since commit e8d55172544c1fafe31a9e09346bdebca4f0d6f9 qemu driver checks
emulator capabilities during domain XML post-parse. However, test suite
does not initialize it, therefore a condition to skip all checks if there
is no cache supplied was added. This is actually a hack, whose sole
purpose is to make existing test suite working. Additionally, it prevents
from writing new tests for this particular functionality.
This series solves this problem by implementing proper cache mockup in test
suite. The main idea is to create a cache in standard way and put there
pre-defined capabilities sets (which tests already have).
In this implementation we introduce "test capability sets", which are named
entities. virQEMUCapsCacheLookup() now has a test mode, which is enabled
by setting qemuTestCapsName variable to the name of capability set which
we want to use in current test. This is based on Martin Kletzander's idea
to implement test mode with assertions. Currently, since name of capability
set is different from /usr/bin/something, we will get errors if we try to
do something with the host filesystem. This is achieved by setting cacheDir
and libDir of our mockup cache to "/dev/null".
The concept of using named capability sets allows us to further improve the
test suite. Now it is possibe to get rid of hardcoded capability sets
and replace them with XML files, readable by virQEMUCapsInitCached().
This will allow us to better exercise our capabilities parser. Taking this
into account, qemuTestCapsCacheInsert() is actually temporary. It will not
be needed any more when capabilities are moved to XML files.
Additionally, some small refactoring is done, and common driver
initialization and cleanup sequence is put into two functions:
qemuTestDriverInit() and qemuTestDriverFree().
I don't include changelist because this is a major rework of the RFC,
almost everything has been changed.
Pavel Fedin (3):
Implement infrastracture for mocking up QEMU capabilities cache
Use mockup cache
Removed unneeded check
src/qemu/qemu_capabilities.c | 16 +++++-------
src/qemu/qemu_capspriv.h | 36 +++++++++++++++++++++++++
src/qemu/qemu_domain.c | 5 +---
tests/qemuagenttest.c | 18 +++++++++----
tests/qemuargv2xmltest.c | 19 +++++++-------
tests/qemuhotplugtest.c | 32 ++++++++++++-----------
tests/qemuxml2argvtest.c | 17 ++++++------
tests/qemuxml2xmltest.c | 16 ++++++++----
tests/qemuxmlnstest.c | 17 ++++++------
tests/testutilsqemu.c | 62 ++++++++++++++++++++++++++++++++++++++++++++
tests/testutilsqemu.h | 9 +++++++
11 files changed, 182 insertions(+), 65 deletions(-)
mode change 100644 => 100755 src/qemu/qemu_capabilities.c
create mode 100644 src/qemu/qemu_capspriv.h
mode change 100644 => 100755 tests/qemuagenttest.c
mode change 100644 => 100755 tests/qemuargv2xmltest.c
mode change 100644 => 100755 tests/qemuhotplugtest.c
mode change 100644 => 100755 tests/qemuxml2argvtest.c
mode change 100644 => 100755 tests/qemuxml2xmltest.c
mode change 100644 => 100755 tests/qemuxmlnstest.c
mode change 100644 => 100755 tests/testutilsqemu.c
mode change 100644 => 100755 tests/testutilsqemu.h
--
2.1.4
9 years, 2 months
[libvirt] [PATCH] conf/qemu: enforce NUMA nodes only for x86 memory hotplug
by Nikunj A Dadhania
libvirt enforces at least one NUMA node for memory hotplug support on
all architectures. While it might be required for some x86 guest,
PowerPC can hotplug memory on non-NUMA system.
The generic checks are replaced with arch specific check and xml
validation too does not enforce "node" for non-x86 arch.
CC: Peter Krempa <pkrempa(a)redhat.com>
Signed-off-by: Nikunj A Dadhania <nikunj(a)linux.vnet.ibm.com>
---
src/conf/domain_conf.c | 9 ++++++---
src/qemu/qemu_command.c | 28 +++++++++++++++++-----------
2 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index fd0450f..4cb2d4a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12430,6 +12430,7 @@ virDomainMemorySourceDefParseXML(xmlNodePtr node,
static int
virDomainMemoryTargetDefParseXML(xmlNodePtr node,
+ const virDomainDef *domDef,
xmlXPathContextPtr ctxt,
virDomainMemoryDefPtr def)
{
@@ -12437,7 +12438,7 @@ virDomainMemoryTargetDefParseXML(xmlNodePtr node,
xmlNodePtr save = ctxt->node;
ctxt->node = node;
- if (virXPathUInt("string(./node)", ctxt, &def->targetNode) < 0) {
+ if (virXPathUInt("string(./node)", ctxt, &def->targetNode) < 0 && ARCH_IS_X86(domDef->os.arch)) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("invalid or missing value of memory device node"));
goto cleanup;
@@ -12457,6 +12458,7 @@ virDomainMemoryTargetDefParseXML(xmlNodePtr node,
static virDomainMemoryDefPtr
virDomainMemoryDefParseXML(xmlNodePtr memdevNode,
+ const virDomainDef *domDef,
xmlXPathContextPtr ctxt,
unsigned int flags)
{
@@ -12495,7 +12497,7 @@ virDomainMemoryDefParseXML(xmlNodePtr memdevNode,
goto error;
}
- if (virDomainMemoryTargetDefParseXML(node, ctxt, def) < 0)
+ if (virDomainMemoryTargetDefParseXML(node, domDef, ctxt, def) < 0)
goto error;
if (virDomainDeviceInfoParseXML(memdevNode, NULL, &def->info, flags) < 0)
@@ -12647,7 +12649,7 @@ virDomainDeviceDefParse(const char *xmlStr,
goto error;
break;
case VIR_DOMAIN_DEVICE_MEMORY:
- if (!(dev->data.memory = virDomainMemoryDefParseXML(node, ctxt, flags)))
+ if (!(dev->data.memory = virDomainMemoryDefParseXML(node, def, ctxt, flags)))
goto error;
break;
case VIR_DOMAIN_DEVICE_NONE:
@@ -16328,6 +16330,7 @@ virDomainDefParseXML(xmlDocPtr xml,
for (i = 0; i < n; i++) {
virDomainMemoryDefPtr mem = virDomainMemoryDefParseXML(nodes[i],
+ def,
ctxt,
flags);
if (!mem)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index ae03618..51160e7 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4979,8 +4979,12 @@ qemuBuildMemoryBackendStr(unsigned long long size,
*backendProps = NULL;
*backendType = NULL;
- /* memory devices could provide a invalid guest node */
- if (guestNode >= virDomainNumaGetNodeCount(def->numa)) {
+ /* memory devices could provide a invalid guest node. Moreover,
+ * x86 guests needs at least one numa node to support memory
+ * hotplug
+ */
+ if ((virDomainNumaGetNodeCount(def->numa) == 0 && ARCH_IS_X86(def->os.arch)) ||
+ guestNode > virDomainNumaGetNodeCount(def->numa)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("can't add memory backend for guest node '%d' as "
"the guest has only '%zu' NUMA nodes configured"),
@@ -4991,10 +4995,12 @@ qemuBuildMemoryBackendStr(unsigned long long size,
if (!(props = virJSONValueNewObject()))
return -1;
- memAccess = virDomainNumaGetNodeMemoryAccessMode(def->numa, guestNode);
- if (virDomainNumatuneGetMode(def->numa, guestNode, &mode) < 0 &&
- virDomainNumatuneGetMode(def->numa, -1, &mode) < 0)
- mode = VIR_DOMAIN_NUMATUNE_MEM_STRICT;
+ if (virDomainNumaGetNodeCount(def->numa)) {
+ memAccess = virDomainNumaGetNodeMemoryAccessMode(def->numa, guestNode);
+ if (virDomainNumatuneGetMode(def->numa, guestNode, &mode) < 0 &&
+ virDomainNumatuneGetMode(def->numa, -1, &mode) < 0)
+ mode = VIR_DOMAIN_NUMATUNE_MEM_STRICT;
+ }
if (pagesize == 0) {
/* Find the huge page size we want to use */
@@ -9238,11 +9244,11 @@ qemuBuildCommandLine(virConnectPtr conn,
goto error;
}
- /* due to guest support, qemu would silently enable NUMA with one node
- * once the memory hotplug backend is enabled. To avoid possible
- * confusion we will enforce user originated numa configuration along
- * with memory hotplug. */
- if (virDomainNumaGetNodeCount(def->numa) == 0) {
+ /* x86 windows guest needs at least one numa node to be
+ * present. While its not possible to detect what guest os is
+ * running, enforce this limitation only to x86 architecture.
+ */
+ if (ARCH_IS_X86(def->os.arch) && virDomainNumaGetNodeCount(def->numa) == 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("At least one numa node has to be configured when "
"enabling memory hotplug"));
--
2.4.3
9 years, 2 months
[libvirt] [PATCH] rbd: Remove snapshots if the FORCED flag has been provided
by Wido den Hollander
When a RBD volume has snapshots it can not be removed.
This patch introduces a new flag to force volume removal,
VIR_STORAGE_VOL_DELETE_FORCED.
With this flag any existing snapshots will be removed prior
to removing the volume.
No existing mechanism in libvirt allowed us to pass such information,
so that's why a new flag was introduced.
Signed-off-by: Wido den Hollander <wido(a)widodh.nl>
---
include/libvirt/libvirt-storage.h | 1 +
src/storage/storage_backend_rbd.c | 58 +++++++++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+)
diff --git a/include/libvirt/libvirt-storage.h b/include/libvirt/libvirt-storage.h
index 453089e..36ff979 100644
--- a/include/libvirt/libvirt-storage.h
+++ b/include/libvirt/libvirt-storage.h
@@ -115,6 +115,7 @@ typedef enum {
typedef enum {
VIR_STORAGE_VOL_DELETE_NORMAL = 0, /* Delete metadata only (fast) */
VIR_STORAGE_VOL_DELETE_ZEROED = 1 << 0, /* Clear all data to zeros (slow) */
+ VIR_STORAGE_VOL_DELETE_FORCED = 2, /* Force removal of volume, even if in use */
} virStorageVolDeleteFlags;
typedef enum {
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index ac5085a..ca5e802 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -428,9 +428,13 @@ static int virStorageBackendRBDDeleteVol(virConnectPtr conn,
{
int ret = -1;
int r = 0;
+ int max_snaps = 128;
+ int i, snap_count, protected;
virStorageBackendRBDState ptr;
ptr.cluster = NULL;
ptr.ioctx = NULL;
+ rbd_snap_info_t *snaps;
+ rbd_image_t image = NULL;
VIR_DEBUG("Removing RBD image %s/%s", pool->def->source.name, vol->name);
@@ -443,6 +447,59 @@ static int virStorageBackendRBDDeleteVol(virConnectPtr conn,
if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0)
goto cleanup;
+ r = rbd_open(ptr.ioctx, vol->name, &image, NULL);
+ if (r < 0) {
+ virReportSystemError(-r, _("failed to open the RBD image '%s'"),
+ vol->name);
+ goto cleanup;
+ }
+
+ do {
+ if (VIR_ALLOC_N(snaps, max_snaps))
+ goto cleanup;
+
+ snap_count = rbd_snap_list(image, snaps, &max_snaps);
+ if (snap_count <= 0) {
+ VIR_FREE(snaps);
+ }
+ } while (snap_count == -ERANGE);
+
+ VIR_DEBUG("Found %d snapshots for volume %s/%s", snap_count,
+ pool->def->source.name, vol->name);
+
+ if (snap_count > 0 && (flags & VIR_STORAGE_VOL_DELETE_FORCED)) {
+ for (i = 0; i < snap_count; i++) {
+ if (rbd_snap_is_protected(image, snaps[i].name, &protected))
+ goto cleanup;
+
+ if (protected == 1) {
+ VIR_DEBUG("Snapshot %s/%s@%s is protected needs to be "
+ "unprotected", pool->def->source.name, vol->name,
+ snaps[i].name);
+
+ if (rbd_snap_unprotect(image, snaps[i].name) < 0)
+ goto cleanup;
+ }
+
+ VIR_DEBUG("Removing snapshot %s/%s@%s", pool->def->source.name,
+ vol->name, snaps[i].name);
+
+ if (rbd_snap_remove(image, snaps[i].name) < 0) {
+ virReportSystemError(-r, _("failed to remove snapshot '%s/%s@%s'"),
+ pool->def->source.name, vol->name,
+ snaps[i].name);
+ goto cleanup;
+ }
+ }
+
+ rbd_snap_list_end(snaps);
+ }
+
+ if (rbd_close(image) < 0)
+ goto cleanup;
+
+ VIR_DEBUG("Removing volume %s/%s", pool->def->source.name, vol->name);
+
r = rbd_remove(ptr.ioctx, vol->name);
if (r < 0 && (-r) != ENOENT) {
virReportSystemError(-r, _("failed to remove volume '%s/%s'"),
@@ -453,6 +510,7 @@ static int virStorageBackendRBDDeleteVol(virConnectPtr conn,
ret = 0;
cleanup:
+ VIR_FREE(snaps);
virStorageBackendRBDCloseRADOSConn(&ptr);
return ret;
}
--
1.9.1
9 years, 2 months
[libvirt] [PATCH] qemuDomainUpdateDeviceConfig: Allow startupPolicy update, yet again
by Michal Privoznik
https://bugzilla.redhat.com/show_bug.cgi?id=1159219
So, in 11e058ca589808bd I've tried to make UpdateDevice update
startupPolicy too. And it worked well until somebody came around
and pushed d0dc6c036914da which accidentally removed my
contribution. Redo my commit.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_driver.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 91eb661..03ef972 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8353,6 +8353,7 @@ qemuDomainUpdateDeviceConfig(virQEMUCapsPtr qemuCaps,
* We allow updating src/type//driverType/cachemode/
*/
orig->cachemode = disk->cachemode;
+ orig->startupPolicy = disk->startupPolicy;
virStorageSourceFree(orig->src);
orig->src = disk->src;
--
2.4.6
9 years, 2 months
[libvirt] [PATCH] util: Add space before comment end marker
by Andrea Bolognani
This allows the Wikipedia link to be recognized correctly by eg.
gnome-terminal's Open Link and Copy Link Address features.
---
Pushed as trivial
src/util/virarch.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virarch.h b/src/util/virarch.h
index 3206ce2..af5ff83 100644
--- a/src/util/virarch.h
+++ b/src/util/virarch.h
@@ -45,7 +45,7 @@ typedef enum {
VIR_ARCH_MIPS64, /* MIPS 64 BE http://en.wikipedia.org/wiki/MIPS_architecture */
VIR_ARCH_MIPS64EL, /* MIPS 64 LE http://en.wikipedia.org/wiki/MIPS_architecture */
- VIR_ARCH_OR32, /* OpenRisc 32 BE http://en.wikipedia.org/wiki/OpenRISC#QEMU_support*/
+ VIR_ARCH_OR32, /* OpenRisc 32 BE http://en.wikipedia.org/wiki/OpenRISC#QEMU_support */
VIR_ARCH_PARISC, /* PA-Risc 32 BE http://en.wikipedia.org/wiki/PA-RISC */
VIR_ARCH_PARISC64, /* PA-Risc 64 BE http://en.wikipedia.org/wiki/PA-RISC */
--
2.4.3
9 years, 2 months