[libvirt] [PATCH v2 0/12] migration: support all toURI and proto combos
by Nikolay Shirokovskiy
Current implementation of 'toURI' migration interfaces does not support all
combinations of interface versions and protocol versions. For example 'toURI2'
with p2p flag will not migrate if driver supports only v3params proto.
This is not convinient as drivers that starts to support migration have to
manually support older versions of protocol. I guess this should be done in
one place, namely here.
Another issue is that there are a lot of code duplication in implementation of
toURI interfaces and it is not obvious from code how are they related.
This implementation uses extensible parameters as intermediate parameters
representation. This is possible as interfaces are done backward compatible in
terms of parameters and later versions supports all parameters of former
versions.
= Changes from version1
Patch is splitted into a set. Quite a big one as a result of the following strategy:
1. each change in behaviour even subtle one deserves a separate patch. One
patch changes one aspect in behaviour.
2. separate pure refactoring steps into patches too as rather simple refactor
steps could introduce many line changes. Mark such patches with 'refactor:'
Now every patch is easy to grasp I think.
The resulted cumulative patch is slightly different from first in behaviour but
I'm not going to describe the differece here as original patch was not reviewed
in details by anyone anyway )
src/libvirt-domain.c | 520 +++++++++++++++++++++-----------------------------
1 files changed, 216 insertions(+), 304 deletions(-)
9 years, 3 months
Re: [libvirt] [Qemu-devel] internal snapshots with sheepdog
by Kevin Wolf
Am 18.09.2015 um 11:03 hat Vasiliy Tolstov geschrieben:
> 2015-09-18 12:02 GMT+03:00 Kevin Wolf <kwolf(a)redhat.com>:
> > Doesn't sheepdog already support storing snapshots in the same image?
> > I thought it would just work; at least, there's some code there for it.
>
> Yes, qemu and sheepdog have ability to create internal snapshot, i
> miss that, but when i'm try in libvirt create live snapshot - libvirt
> says, that this is not possible with raw image.
Then I guess your mail should be directed to the libvirt list instead
(CCed).
Kevin
9 years, 3 months
[libvirt] [PATCH] libxl: fix AttachDeviceConfig on hostdev type
by Chunyan Liu
After attach-device a <hostdev> with --config, new device doesn't
show up in dumpxml and in guest.
To fix that, set dev->data.hostdev = NULL after work so that the
pointer is not freed, since vmdef has the pointer and still need it.
Signed-off-by: Chunyan Liu <cyliu(a)suse.com>
---
src/libxl/libxl_driver.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index e2797d5..8087c27 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -3312,6 +3312,7 @@ libxlDomainAttachDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev)
if (virDomainHostdevInsert(vmdef, hostdev) < 0)
return -1;
+ dev->data.hostdev = NULL;
break;
default:
--
1.8.5.6
9 years, 3 months
[libvirt] VMware: Map vpx:// to dcPath
by Richard W.M. Jones
vpx:// paths looks like this:
vpx://vcenter.example.com/MyFolder/MyDatacenter/MyCluster/esxi
but to connect to the datastore to read the underlying disk image,
libguestfs must form a URL like this:
https://vcenter.example.com/folder/data/guest/guest-flat.vmdk?dcPath=MyFo...
All parts of this URL can be worked out from the URL or the libvirt
XML *except* the ?dcPath=... parameter.
The problem is that dcPath isn't a straight mapping from the vpx://
path. The particular problem is that if there is a cluster name in
the path (eg 'MyCluster') it appears that we have to remove it. ie:
dcPath=MyFolder/MyDatacenter/MyCluster - does not work
dcPath=MyFolder/MyDatacenter - works
That would be OK if there was always a cluster name at the end of the
path, but there isn't. Clusters are completely optional, and AFAIK
you can't tell if something is a cluster path element just by
examining the name, since clusters can be given arbitrary names by the
vCenter admin.
So:
(1) Is there something I'm missing here? Maybe the libvirt VMware
driver presents this information already and I'm just missing it?
(2) Can we add some way to more easily map from vpx:// paths to
datastore URLs? The whole process is very complex even without the
ambiguity - it takes a couple of pages of code to do the mapping.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top
9 years, 3 months
[libvirt] [PATCH v3] qemu: Validate address type when attaching a disk device.
by Ruifeng Bian
Bug fix for: https://bugzilla.redhat.com/show_bug.cgi?id=1257844
Attach-device can hotplug a virtio disk device with any address type now,
it need to validate the address type before the attachment.
Attaching a disk device with --config option need to check address type.
Otherwise, the domain cloudn't be started normally. This patch add a basic
check for address type.
Detaching a disk device with --config also need to check disk options,
add qemuCheckDiskConfig() method in qemuDomainDetachDeviceConfig().
---
src/qemu/qemu_command.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
src/qemu/qemu_driver.c | 2 ++
src/qemu/qemu_hotplug.c | 22 ++++++++++++++++++++++
3 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index ec5e3d4..a2c7483 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3579,12 +3579,54 @@ qemuCheckDiskConfig(virDomainDiskDefPtr disk)
goto error;
}
}
+
+ if (disk->info.type) {
+ switch (disk->bus) {
+ case VIR_DOMAIN_DISK_BUS_IDE:
+ case VIR_DOMAIN_DISK_BUS_SCSI:
+ case VIR_DOMAIN_DISK_BUS_SATA:
+ case VIR_DOMAIN_DISK_BUS_FDC:
+ if (disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("disk cannot have an address of type '%s'"),
+ virDomainDeviceAddressTypeToString(disk->info.type));
+ goto error;
+ }
+ break;
+ case VIR_DOMAIN_DISK_BUS_USB:
+ if (disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("usb disk cannot have an address of type '%s'"),
+ virDomainDeviceAddressTypeToString(disk->info.type));
+ goto error;
+ }
+ break;
+ case VIR_DOMAIN_DISK_BUS_VIRTIO:
+ if (disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW &&
+ disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390 &&
+ disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO &&
+ disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("virtio disk cannot have an address of type '%s'"),
+ virDomainDeviceAddressTypeToString(disk->info.type));
+ goto error;
+ }
+ break;
+ case VIR_DOMAIN_DISK_BUS_XEN:
+ case VIR_DOMAIN_DISK_BUS_UML:
+ case VIR_DOMAIN_DISK_BUS_SD:
+ /* no address type currently, return false if address provided */
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("disk cannot have an address of type '%s'"),
+ virDomainDeviceAddressTypeToString(disk->info.type));
+ goto error;
+ }
+ }
return 0;
error:
return -1;
}
-
/* Check whether the device address is using either 'ccw' or default s390
* address format and whether that's "legal" for the current qemu and/or
* guest os.machine type. This is the corollary to the code which doesn't
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 91eb661..61424b0 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8205,6 +8205,8 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
switch ((virDomainDeviceType) dev->type) {
case VIR_DOMAIN_DEVICE_DISK:
disk = dev->data.disk;
+ if (qemuCheckDiskConfig(disk) < 0)
+ return -1;
if (!(det_disk = virDomainDiskRemoveByName(vmdef, disk->dst))) {
virReportError(VIR_ERR_INVALID_ARG,
_("no target device %s"), disk->dst);
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 63fafa6..1f46647 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -335,6 +335,28 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
if (!qemuCheckCCWS390AddressSupport(vm->def, disk->info, priv->qemuCaps,
disk->dst))
goto cleanup;
+
+ if (qemuDomainMachineIsS390CCW(vm->def) &&
+ virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
+ if (!virDomainDeviceAddressIsValid(&disk->info,
+ VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)) {
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+ _("device cannot be attached without a valid CCW address"));
+ goto cleanup;
+ }
+ } else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) {
+ if (!virDomainDeviceAddressIsValid(&disk->info,
+ VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390)) {
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+ _("device cannot be attached without a valid S390 address"));
+ goto cleanup;
+ }
+ } else if (!virDomainDeviceAddressIsValid(&disk->info,
+ VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) {
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+ _("device cannot be attached without a valid PCI address"));
+ goto cleanup;
+ }
}
for (i = 0; i < vm->def->ndisks; i++) {
--
2.4.3
9 years, 3 months
[libvirt] [PATCH v2] virfile: Check for existence of dir in virFileDeleteTree
by John Ferlan
Commit id 'f1f68ca33' added code to remove the directory paths for
auto-generated sockets, but that code could be called before the
paths were created resulting in generating error messages from
virFileDeleteTree indicating that the file doesn't exist.
Rather than "enforce" all callers to make the non-NULL and existence
checks, modify the virFileDeleteTree API to silently ignore NULL on
input and non-existent directory trees.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
Difference over v1: Add checks in virFileDeleteTree
src/qemu/qemu_process.c | 6 ++----
src/util/virfile.c | 8 ++++++--
tests/virhostdevtest.c | 2 +-
tests/virscsitest.c | 2 +-
4 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index ce2c70c..155846e 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5269,14 +5269,12 @@ void qemuProcessStop(virQEMUDriverPtr driver,
ignore_value(virAsprintf(&tmppath, "%s/domain-%s",
cfg->libDir, vm->def->name));
- if (tmppath)
- virFileDeleteTree(tmppath);
+ virFileDeleteTree(tmppath);
VIR_FREE(tmppath);
ignore_value(virAsprintf(&tmppath, "%s/domain-%s",
cfg->channelTargetDir, vm->def->name));
- if (tmppath)
- virFileDeleteTree(tmppath);
+ virFileDeleteTree(tmppath);
VIR_FREE(tmppath);
ignore_value(virDomainChrDefForeach(vm->def,
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 75819d9..fe9f8d4 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -934,13 +934,17 @@ int virFileNBDDeviceAssociate(const char *file,
*/
int virFileDeleteTree(const char *dir)
{
- DIR *dh = opendir(dir);
+ DIR *dh;
struct dirent *de;
char *filepath = NULL;
int ret = -1;
int direrr;
- if (!dh) {
+ /* Silently return 0 if passed NULL or directory doesn't exist */
+ if (!dir || !virFileExists(dir))
+ return 0;
+
+ if (!(dh = opendir(dir))) {
virReportSystemError(errno, _("Cannot open dir '%s'"),
dir);
return -1;
diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c
index 1e93819..065b825 100644
--- a/tests/virhostdevtest.c
+++ b/tests/virhostdevtest.c
@@ -65,7 +65,7 @@ myCleanup(void)
}
if (mgr) {
- if (mgr->stateDir && !getenv("LIBVIRT_SKIP_CLEANUP"))
+ if (!getenv("LIBVIRT_SKIP_CLEANUP"))
virFileDeleteTree(mgr->stateDir);
virObjectUnref(mgr->activePCIHostdevs);
diff --git a/tests/virscsitest.c b/tests/virscsitest.c
index a86ca28..88286f1 100644
--- a/tests/virscsitest.c
+++ b/tests/virscsitest.c
@@ -241,7 +241,7 @@ mymain(void)
ret = -1;
cleanup:
- if (tmpdir && getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
+ if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
virFileDeleteTree(tmpdir);
VIR_FREE(virscsi_prefix);
return ret;
--
2.1.0
9 years, 3 months
[libvirt] [PATCH] qemu: Check for existence of auto-generated socket path before removing
by John Ferlan
Commit id 'f1f68ca33' added code to remove the directory paths for
auto-generated sockets, but that code could be called before the
paths were created resulting in generating error messages from
virFileDeleteTree indicating that the file doesn't exist. So just
add a check before attemping the directory delete for existence.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/qemu/qemu_process.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index ce2c70c..b55eb52 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5269,13 +5269,13 @@ void qemuProcessStop(virQEMUDriverPtr driver,
ignore_value(virAsprintf(&tmppath, "%s/domain-%s",
cfg->libDir, vm->def->name));
- if (tmppath)
+ if (tmppath && virFileExists(tmppath))
virFileDeleteTree(tmppath);
VIR_FREE(tmppath);
ignore_value(virAsprintf(&tmppath, "%s/domain-%s",
cfg->channelTargetDir, vm->def->name));
- if (tmppath)
+ if (tmppath && virFileExists(tmppath))
virFileDeleteTree(tmppath);
VIR_FREE(tmppath);
--
2.1.0
9 years, 3 months
[libvirt] [PATCH v2] virsh: Teach attach-interface to --print-xml
by Michal Privoznik
We have the same argument to many other commands that produce an
XML based on what user typed. But unfortunately attach-interface
was missing it. Maybe nobody had needed it yet. Well, I did
just now.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Diff to v1:
- Commit message grammar fix
- Fixed usage of virDomain
tools/virsh-domain.c | 28 ++++++++++++++++++++--------
tools/virsh.pod | 4 ++++
2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index b029b65..ce84930 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -862,6 +862,10 @@ static const vshCmdOptDef opts_attach_interface[] = {
.type = VSH_OT_BOOL,
.help = N_("affect current domain")
},
+ {.name = "print-xml",
+ .type = VSH_OT_BOOL,
+ .help = N_("print XML document rather than attach the interface")
+ },
{.name = NULL}
};
@@ -938,13 +942,6 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
if (live)
flags |= VIR_DOMAIN_AFFECT_LIVE;
- if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
- return false;
-
- if (persistent &&
- virDomainIsActive(dom) == 1)
- flags |= VIR_DOMAIN_AFFECT_LIVE;
-
if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0 ||
vshCommandOptStringReq(ctl, cmd, "source", &source) < 0 ||
vshCommandOptStringReq(ctl, cmd, "target", &target) < 0 ||
@@ -1051,6 +1048,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
virBufferAddLit(&buf, "</bandwidth>\n");
}
+ virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</interface>\n");
if (virBufferError(&buf)) {
@@ -1060,6 +1058,19 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
xml = virBufferContentAndReset(&buf);
+ if (vshCommandOptBool(cmd, "print-xml")) {
+ vshPrint(ctl, "%s", xml);
+ functionReturn = true;
+ goto cleanup;
+ }
+
+ if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+ goto cleanup;
+
+ if (persistent &&
+ virDomainIsActive(dom) == 1)
+ flags |= VIR_DOMAIN_AFFECT_LIVE;
+
if (flags || current)
ret = virDomainAttachDeviceFlags(dom, xml, flags);
else
@@ -1075,7 +1086,8 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
}
cleanup:
- virDomainFree(dom);
+ if (dom)
+ virDomainFree(dom);
virBufferFreeAndReset(&buf);
return functionReturn;
}
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 83c445d3..0212e7a 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -2507,6 +2507,7 @@ Likewise, I<--shareable> is an alias for I<--mode shareable>.
[[[I<--live>] [I<--config>] | [I<--current>]] | [I<--persistent>]]
[I<--target target>] [I<--mac mac>] [I<--script script>] [I<--model model>]
[I<--inbound average,peak,burst,floor>] [I<--outbound average,peak,burst>]
+[I<--print-xml>]
Attach a new network interface to the domain. I<type> can be
I<network> to indicate connection via a libvirt virtual network, or
@@ -2536,6 +2537,9 @@ kilobytes in a single burst at I<peak> speed as described in the
Network XML documentation at
L<http://libvirt.org/formatnetwork.html#elementQoS>.
+If I<--print-xml> is specified, then the XML of the interface that would be
+attached is printed instead.
+
If I<--live> is specified, affect a running domain.
If I<--config> is specified, affect the next startup of a persistent domain.
If I<--current> is specified, affect the current domain state.
--
2.4.6
9 years, 3 months
[libvirt] [PATCH v3] 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 | 105 +++++++++++++++++++++++++++++--------------
1 file changed, 71 insertions(+), 34 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 4ad1bdb..01fbd65 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,55 @@ 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;
+ virArch target;
+
+ /* First attempt: try the guest architecture as it is */
+ archstr = virQEMUCapsArchToString(guestarch);
+ if ((ret = virQEMUCapsFindBinary("qemu-system-%s", archstr)) != NULL)
+ goto out;
+
+ /* Second attempt: try looking up by target instead */
+ target = virQEMUCapsFindTarget(hostarch, guestarch);
+ if (target != guestarch) {
+ archstr = virQEMUCapsArchToString(target);
+ 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);
+ /* Third attempt, i686 only: try 'qemu' */
+ if (guestarch == VIR_ARCH_I686) {
+ if ((ret = virQEMUCapsFindBinary("%s", "qemu")) != NULL)
+ goto out;
}
+ out:
return ret;
}
@@ -3789,14 +3815,25 @@ virQEMUCapsCacheLookupByArch(virQEMUCapsCachePtr cache,
virArch arch)
{
virQEMUCapsPtr ret = NULL;
+ virArch target;
struct virQEMUCapsSearchData data = { .arch = arch };
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 finding capabilities has failed, try
+ * again using the QEMU target as lookup key instead */
+ target = virQEMUCapsFindTarget(virArchFromHost(), data.arch);
+ if (target != data.arch) {
+ data.arch = target;
+ 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, 3 months