Re: [PATCH v3 05/20] Remove probing of CPU models when launching QEMU guests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 25, 2012 at 18:59:58 +0100, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
> 
> When launching a QEMU guest the binary is probed to discover
> the list of supported CPU names. Remove this probing with a
> simple lookup of CPU models in the qemuCapsPtr object. This
> avoids another invocation of the QEMU binary during the
> startup path.
> 
> As a nice benefit we can now remove all the nasty hacks from
> the test suite which were done to avoid having to exec QEMU
> on the test system. The building of the -cpu command line
> can just rely on data we pre-populate in qemuCapsPtr.

Nice, I wanted to do this since I first implemented CPU model probing :-)

> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index dd043a1..c73034d 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -4067,7 +4067,7 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver,
>      virCPUDefPtr guest = NULL;
>      virCPUDefPtr cpu = NULL;
>      size_t ncpus = 0;
> -    const char **cpus = NULL;
> +    char **cpus = NULL;
>      const char *default_model;
>      union cpuData *data = NULL;
>      bool have_cpu = false;
> @@ -4089,12 +4089,8 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver,
>          const char *preferred;
>          int hasSVM;
>  
> -        if (host &&
> -            qemuCapsProbeCPUModels(emulator, caps, host->arch,
> -                                   &ncpus, &cpus) < 0)
> -            goto cleanup;
> -
> -        if (!ncpus || !host) {
> +        if (!host ||
> +            (ncpus = qemuCapsGetCPUDefinitions(caps, &cpus)) == 0) {
>              virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
>                             _("CPU specification not supported by hypervisor"));
>              goto cleanup;
> @@ -4163,7 +4159,7 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver,
>  
>              guest->type = VIR_CPU_TYPE_GUEST;
>              guest->fallback = cpu->fallback;
> -            if (cpuDecode(guest, data, cpus, ncpus, preferred) < 0)
> +            if (cpuDecode(guest, data, (const char **)cpus, ncpus, preferred) < 0)

Hmm, is this typecast really necessary?

>                  goto cleanup;
>  
>              virBufferAdd(&buf, guest->model, -1);
...

ACK

Jirka

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]