[libvirt] [PATCH 4/8] tests/testutilsqemu: extract guest creation into separate functions
Ján Tomko
jtomko at redhat.com
Tue Apr 11 11:25:24 UTC 2017
On Fri, Apr 07, 2017 at 03:44:19PM +0200, Pavel Hrdina wrote:
>All other architectures have separate functions to prepare guest
>capabilities, do the same for i686 and x86_64 as well.
>
>Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
>---
> tests/testutilsqemu.c | 182 +++++++++++++++++++++++++++++++-------------------
> 1 file changed, 114 insertions(+), 68 deletions(-)
>
>diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
>index 4cc482dfb0..d82cebd578 100644
>--- a/tests/testutilsqemu.c
>+++ b/tests/testutilsqemu.c
>@@ -141,6 +141,118 @@ static virCapsGuestMachinePtr *testQemuAllocNewerMachines(int *nmachines)
> }
>
>
>+static int
>+testQemuAddI686Guest(virCapsPtr caps)
>+{
>+ int nmachines = 0;
>+ virCapsGuestMachinePtr *machines = NULL;
>+ virCapsGuestPtr guest;
>+
>+ if (!(machines = testQemuAllocMachines(&nmachines)))
>+ goto error;
>+
>+ if (!(guest = virCapabilitiesAddGuest(caps,
>+ VIR_DOMAIN_OSTYPE_HVM,
>+ VIR_ARCH_I686,
>+ "/usr/bin/qemu",
>+ NULL,
>+ nmachines,
>+ machines)))
>+ goto error;
>+
>+ if (!virCapabilitiesAddGuestFeature(guest, "cpuselection", true, false))
>+ goto error;
>+
>+ machines = NULL;
This is correct from the code movement point of view, but virCapabilitiesAddGuest
transfers the ownership of 'machines' to 'caps', so this assignment
should be above virCapabilitiesAddGuestFeature. Preferably in a
follow-up patch.
>+
>+ if (!virCapabilitiesAddGuestDomain(guest,
>+ VIR_DOMAIN_VIRT_QEMU,
[...]
>+
>+static int
>+testQemuAddX86_64Guest(virCapsPtr caps)
>+{
>+ int nmachines = 0;
>+ virCapsGuestMachinePtr *machines = NULL;
>+ virCapsGuestPtr guest;
>+
>+ if (!(machines = testQemuAllocNewerMachines(&nmachines)))
>+ goto error;
>+
>+ if (!(guest = virCapabilitiesAddGuest(caps,
>+ VIR_DOMAIN_OSTYPE_HVM,
>+ VIR_ARCH_X86_64,
>+ "/usr/bin/qemu-system-x86_64",
>+ NULL,
>+ nmachines,
>+ machines)))
>+ goto error;
>+
>+ if (!virCapabilitiesAddGuestFeature(guest, "cpuselection", true, false))
>+ goto error;
>+
>+ machines = NULL;
Same here.
Jan
>+ if (!virCapabilitiesAddGuestDomain(guest,
>+ VIR_DOMAIN_VIRT_QEMU,
>+ NULL,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170411/1bb1c36b/attachment-0001.sig>
More information about the libvir-list
mailing list