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: NMichal Privoznik <mprivozn@redhat.com>
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
......@@ -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,16 +799,12 @@ virQEMUCapsFindBinaryForArch(virArch hostarch,
return ret;
}
static int
virQEMUCapsInitGuest(virCapsPtr caps,
virFileCachePtr cache,
virArch hostarch,
virArch guestarch)
char *
virQEMUCapsGetDefaultEmulator(virArch hostarch,
virArch guestarch)
{
char *binary = NULL;
virQEMUCapsPtr qemuCaps = NULL;
int ret = -1;
/* Check for existence of base emulator, or alternate base
* which can be used with magic cpu choice
*/
......@@ -819,6 +815,22 @@ virQEMUCapsInitGuest(virCapsPtr caps,
if (virQEMUCapsGuestIsNative(hostarch, guestarch) && !binary)
binary = g_strdup("/usr/libexec/qemu-kvm");
return binary;
}
static int
virQEMUCapsInitGuest(virCapsPtr caps,
virFileCachePtr cache,
virArch hostarch,
virArch guestarch)
{
char *binary = NULL;
virQEMUCapsPtr qemuCaps = NULL;
int ret = -1;
binary = virQEMUCapsGetDefaultEmulator(hostarch, guestarch);
/* Ignore binary if extracting version info fails */
if (binary) {
if (!(qemuCaps = virQEMUCapsCacheLookup(cache, 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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册