mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
conf: drop virCapsPtr param from basic post parse callback
The QEMU impl of the callback can directly use the QEMU capabilities cache to resolve the emulator binary name, allowing virCapsPtr to be dropped. Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
a7ef72a8fd
commit
74fb858f7d
@ -5832,7 +5832,7 @@ virDomainDefPostParse(virDomainDefPtr def,
|
||||
|
||||
/* call the basic post parse callback */
|
||||
if (xmlopt->config.domainPostParseBasicCallback) {
|
||||
ret = xmlopt->config.domainPostParseBasicCallback(def, caps,
|
||||
ret = xmlopt->config.domainPostParseBasicCallback(def,
|
||||
xmlopt->config.priv);
|
||||
|
||||
if (virDomainDefPostParseCheckFailure(def, parseFlags, ret) < 0)
|
||||
|
@ -2627,7 +2627,6 @@ typedef enum {
|
||||
* parseOpaque is used. This callback is run prior to
|
||||
* virDomainDefPostParseCallback. */
|
||||
typedef int (*virDomainDefPostParseBasicCallback)(virDomainDefPtr def,
|
||||
virCapsPtr caps,
|
||||
void *opaque);
|
||||
|
||||
/* Called once after everything else has been parsed, for adjusting
|
||||
|
@ -799,6 +799,26 @@ virQEMUCapsFindBinaryForArch(virArch hostarch,
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
virQEMUCapsGetDefaultEmulator(virArch hostarch,
|
||||
virArch guestarch)
|
||||
{
|
||||
char *binary = NULL;
|
||||
/* Check for existence of base emulator, or alternate base
|
||||
* which can be used with magic cpu choice
|
||||
*/
|
||||
binary = virQEMUCapsFindBinaryForArch(hostarch, guestarch);
|
||||
|
||||
/* RHEL doesn't follow the usual naming for QEMU binaries and ships
|
||||
* a single binary named qemu-kvm outside of $PATH instead */
|
||||
if (virQEMUCapsGuestIsNative(hostarch, guestarch) && !binary)
|
||||
binary = g_strdup("/usr/libexec/qemu-kvm");
|
||||
|
||||
return binary;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virQEMUCapsInitGuest(virCapsPtr caps,
|
||||
virFileCachePtr cache,
|
||||
@ -809,15 +829,7 @@ virQEMUCapsInitGuest(virCapsPtr caps,
|
||||
virQEMUCapsPtr qemuCaps = NULL;
|
||||
int ret = -1;
|
||||
|
||||
/* Check for existence of base emulator, or alternate base
|
||||
* which can be used with magic cpu choice
|
||||
*/
|
||||
binary = virQEMUCapsFindBinaryForArch(hostarch, guestarch);
|
||||
|
||||
/* RHEL doesn't follow the usual naming for QEMU binaries and ships
|
||||
* a single binary named qemu-kvm outside of $PATH instead */
|
||||
if (virQEMUCapsGuestIsNative(hostarch, guestarch) && !binary)
|
||||
binary = g_strdup("/usr/libexec/qemu-kvm");
|
||||
binary = virQEMUCapsGetDefaultEmulator(hostarch, guestarch);
|
||||
|
||||
/* Ignore binary if extracting version info fails */
|
||||
if (binary) {
|
||||
|
@ -627,6 +627,8 @@ const char *virQEMUCapsGetMachineDefaultCPU(virQEMUCapsPtr qemuCaps,
|
||||
void virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps,
|
||||
virDomainVirtType virtType,
|
||||
const char *machineType);
|
||||
char * virQEMUCapsGetDefaultEmulator(virArch hostarch,
|
||||
virArch guestarch);
|
||||
|
||||
virFileCachePtr virQEMUCapsCacheNew(const char *libDir,
|
||||
const char *cacheDir,
|
||||
|
@ -4677,13 +4677,16 @@ qemuDomainDefTsegPostParse(virDomainDefPtr def,
|
||||
|
||||
static int
|
||||
qemuDomainDefPostParseBasic(virDomainDefPtr def,
|
||||
virCapsPtr caps,
|
||||
void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
virQEMUDriverPtr driver = opaque;
|
||||
|
||||
/* check for emulator and create a default one if needed */
|
||||
if (!def->emulator &&
|
||||
!(def->emulator = virDomainDefGetDefaultEmulator(def, caps)))
|
||||
return 1;
|
||||
if (!def->emulator) {
|
||||
if (!(def->emulator = virQEMUCapsGetDefaultEmulator(
|
||||
driver->hostarch, def->os.arch)))
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -93,6 +93,22 @@ static const char *const *kvm_machines[VIR_ARCH_LAST] = {
|
||||
[VIR_ARCH_S390X] = s390x_machines,
|
||||
};
|
||||
|
||||
|
||||
char *
|
||||
virFindFileInPath(const char *file)
|
||||
{
|
||||
if (g_str_has_prefix(file, "qemu-system") ||
|
||||
g_str_equal(file, "qemu-kvm")) {
|
||||
return g_strdup_printf("/usr/bin/%s", file);
|
||||
}
|
||||
|
||||
/* Nothing in tests should be relying on real files
|
||||
* in host OS, so we return NULL to try to force
|
||||
* an error in such a case
|
||||
*/
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
testQemuAddGuest(virCapsPtr caps,
|
||||
virArch arch)
|
||||
|
Loading…
Reference in New Issue
Block a user