]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
8 years agoqemu: Store host-model CPU in qemu capabilities
Jiri Denemark [Wed, 15 Jun 2016 12:35:18 +0000 (14:35 +0200)]
qemu: Store host-model CPU in qemu capabilities

Host capabilities provide libvirt's view of the host CPU, but for a
useful support for host-model CPUs we really need a hypervisor's view of
the CPU. And since the view can be differ with emulator, qemu
capabilities is the best place to store the host CPU model.

This patch just copies the CPU model from host capabilities, but this
will change in the future.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoconf: Introduce virCPUDefCopyModelFilter
Jiri Denemark [Tue, 28 Jun 2016 08:44:20 +0000 (10:44 +0200)]
conf: Introduce virCPUDefCopyModelFilter

The function filters all CPU features through a given callback while
copying CPU model related parts of a CPU definition.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoconf: Introduce virCPUDefStealModel
Jiri Denemark [Thu, 23 Jun 2016 10:54:19 +0000 (12:54 +0200)]
conf: Introduce virCPUDefStealModel

The function moves CPU model related parts from one CPU definition to
another. It can be used to avoid unnecessary copies from a temporary CPU
definitions which will be freed anyway.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoconf: Introduce virCPUDefCopyWithoutModel
Jiri Denemark [Fri, 17 Jun 2016 07:44:43 +0000 (09:44 +0200)]
conf: Introduce virCPUDefCopyWithoutModel

Useful for copying a CPU definition without model related parts (i.e.,
without model name, feature list, vendor).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Propagate virCapsPtr to virQEMUCapsNewForBinaryInternal
Jiri Denemark [Wed, 15 Jun 2016 11:48:19 +0000 (13:48 +0200)]
qemu: Propagate virCapsPtr to virQEMUCapsNewForBinaryInternal

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoschema: Separate CPU related definitions into cputypes.rng
Jiri Denemark [Tue, 10 May 2016 14:17:08 +0000 (16:17 +0200)]
schema: Separate CPU related definitions into cputypes.rng

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agodomcaps: Add CPU usable flag
Jiri Denemark [Wed, 15 Jun 2016 14:15:44 +0000 (16:15 +0200)]
domcaps: Add CPU usable flag

In case a hypervisor is able to tell us a list of supported CPU models
and whether each CPU models can be used on the current host, we can
propagate this to domain capabilities. This is a better alternative
to calling virConnectCompareCPU for each supported CPU model.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agodomcaps: Show only CPU models supported by libvirt
Jiri Denemark [Fri, 29 Apr 2016 08:42:56 +0000 (10:42 +0200)]
domcaps: Show only CPU models supported by libvirt

Listing all CPU models supported by QEMU in domain capabilities makes
little sense when libvirt will refuse any model it doesn't know about.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu: Don't overwrite errors in cpuGetModels
Jiri Denemark [Thu, 16 Jun 2016 14:08:30 +0000 (16:08 +0200)]
cpu: Don't overwrite errors in cpuGetModels

cpuGetSubDriver already reports a useful error.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu: Special case models == NULL in cpuGetModels
Jiri Denemark [Tue, 14 Jun 2016 09:12:49 +0000 (11:12 +0200)]
cpu: Special case models == NULL in cpuGetModels

Some CPU drivers (such as arm) do not provide list of CPUs libvirt
supports and just pass any CPU model from domain XML directly to QEMU.
Such driver need to return models == NULL and success from cpuGetModels.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Fill in CPU domain capabilities
Jiri Denemark [Fri, 22 Apr 2016 20:22:30 +0000 (22:22 +0200)]
qemu: Fill in CPU domain capabilities

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Introduce virQEMUCapsGuestIsNative
Jiri Denemark [Tue, 14 Jun 2016 15:25:58 +0000 (17:25 +0200)]
qemu: Introduce virQEMUCapsGuestIsNative

To have a single place where we decide whether a guest can run natively
on a host.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemuxml2argvtest: Reorder CPU features
Jiri Denemark [Fri, 5 Aug 2016 12:42:15 +0000 (14:42 +0200)]
qemuxml2argvtest: Reorder CPU features

The x86 CPU driver translated each CPU definition from domain XML into
CPUID data and then back to CPU definition. This effectively sorted the
list of CPU features according to their CPUID values. Since this is
going to change, we need to reorder CPU features in a few test files to
make sure the generated QEMU command lines will not change.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemuxml2argvtest: Set correct architecture for KVM guests
Jiri Denemark [Thu, 4 Aug 2016 11:19:39 +0000 (13:19 +0200)]
qemuxml2argvtest: Set correct architecture for KVM guests

Testing PPC64/AArch64 KVM domains on x86_64 host only works because we
have a lot of bugs in our code. Since this series is going to fix them,
we need to make sure the host architecture matches guest for KVM
domains.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemuxml2argvtest: Properly setup CPU models in qemuCaps
Jiri Denemark [Thu, 4 Aug 2016 11:25:02 +0000 (13:25 +0200)]
qemuxml2argvtest: Properly setup CPU models in qemuCaps

Adding x86 CPU models into a list of supported CPUs for non-x86
architectures is not a very good idea. Each architecture we test needs
to maintain its own list of supported CPU models.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Separate guest CPU validation from command line creation
Jiri Denemark [Thu, 4 Aug 2016 06:25:55 +0000 (08:25 +0200)]
qemu: Separate guest CPU validation from command line creation

qemu_command.c should deal with translating our domain definition into a
QEMU command line and nothing else.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agotestutilsqemu: Add default CPU for PPC64 architectures
Jiri Denemark [Tue, 13 Sep 2016 20:27:09 +0000 (22:27 +0200)]
testutilsqemu: Add default CPU for PPC64 architectures

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agotestutilsqemu: Helpers for changing host CPU and arch
Jiri Denemark [Thu, 4 Aug 2016 11:16:55 +0000 (13:16 +0200)]
testutilsqemu: Helpers for changing host CPU and arch

Changing a host architecture or a CPU is not as easy as assigning a new
value to the appropriate element in virCaps since there is a relation
between the CPU and host architecture (we don't really want to test
anything on an AArch64 host with core2duo CPU). This patch introduces
qemuTestSetHostArch and qemuTestSetHostCPU helpers which will make sure
the host architecture matches the host CPU.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemuxml2argvtest: Properly initialize qemuCaps->arch
Jiri Denemark [Wed, 3 Aug 2016 10:26:41 +0000 (12:26 +0200)]
qemuxml2argvtest: Properly initialize qemuCaps->arch

qemuCaps->arch should match the guest architecture from domain XML.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemuxml2argvtest: Update qemuCaps after parsing domain XML
Jiri Denemark [Wed, 3 Aug 2016 10:21:19 +0000 (12:21 +0200)]
qemuxml2argvtest: Update qemuCaps after parsing domain XML

Some parts of qemuCaps depend on guest architecture, machine type, and
possibly other things that we know only once the domain XML has been
parsed. Let's move all these updates into a dedicated function.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemuxml2argvtest: Reorder functions
Jiri Denemark [Wed, 3 Aug 2016 08:47:00 +0000 (10:47 +0200)]
qemuxml2argvtest: Reorder functions

testCompareXMLToArgv will soon need to call a few function which are
defined further in the code. Let's move them up a bit.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemuxml2argvtest: Get rid of testCompareXMLToArgvHelper
Jiri Denemark [Wed, 3 Aug 2016 08:42:08 +0000 (10:42 +0200)]
qemuxml2argvtest: Get rid of testCompareXMLToArgvHelper

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemuxml2argvtest: Rename "out" labels as "cleanup"
Jiri Denemark [Wed, 3 Aug 2016 08:19:10 +0000 (10:19 +0200)]
qemuxml2argvtest: Rename "out" labels as "cleanup"

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemuxml2argvtest: Rename extraFlags as qemuCaps
Jiri Denemark [Wed, 3 Aug 2016 07:49:42 +0000 (09:49 +0200)]
qemuxml2argvtest: Rename extraFlags as qemuCaps

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Use virDomainCapsCPUModels for cpuDefinitions
Jiri Denemark [Thu, 21 Apr 2016 10:51:01 +0000 (12:51 +0200)]
qemu: Use virDomainCapsCPUModels for cpuDefinitions

The list of supported CPU models in domain capabilities is stored in
virDomainCapsCPUModels. Let's use the same object for storing CPU models
in QEMU capabilities.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agodomcaps: Add support for listing supported CPU models
Jiri Denemark [Fri, 22 Apr 2016 09:08:57 +0000 (11:08 +0200)]
domcaps: Add support for listing supported CPU models

The patch adds <cpu> element to domain capabilities XML:

    <cpu>
        <mode name='host-passthrough' supported='yes'/>
        <mode name='host-model' supported='yes'/>
        <mode name='custom' supported='yes'>
            <model>Broadwell</model>
            <model>Broadwell-noTSX</model>
            ...
        </mode>
    </cpu>

Applications can use it to inspect what CPU configuration modes are
supported for a specific combination of domain type, emulator binary,
guest architecture and machine type.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpuGetModels: Switch to virArch
Jiri Denemark [Fri, 29 Apr 2016 08:38:03 +0000 (10:38 +0200)]
cpuGetModels: Switch to virArch

Our internal APIs mostly use virArch rather than strings. Switching
cpuGetModels to virArch will save us from unnecessary conversions in the
future.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agolibxl: support VIR_MIGRATE_PERSIST_DEST migration flag
Jim Fehlig [Mon, 19 Sep 2016 17:34:34 +0000 (11:34 -0600)]
libxl: support VIR_MIGRATE_PERSIST_DEST migration flag

By default, virt-manager (and likely other libvirt-based apps) sets
the VIR_MIGRATE_PERSIST_DEST flag when invoking the migrate API, which
fails in a Xen setup since the libxl driver does not support the flag.

Persisting a domain is a trivial task in the grand scheme of migration,
so be nice to libvirt apps and add support for VIR_MIGRATE_PERSIST_DEST
in the libxl driver.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
8 years agoqemu_process: move graphics validation into separate function
Pavel Hrdina [Tue, 20 Sep 2016 11:49:21 +0000 (13:49 +0200)]
qemu_process: move graphics validation into separate function

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_process: show shutoff reasons when debug log disabled
Chen Hanxiao [Mon, 19 Sep 2016 08:17:57 +0000 (16:17 +0800)]
qemu_process: show shutoff reasons when debug log disabled

We have a few of senarios that libvirtd would invoke qemuProcessStop
and leave a "shutting down" in /var/log/libvirt/qemu/$DOMAIN.log.

The shutoff reason showing in debug log is also very important
for us to know why VM shutting down in domain log,
as we seldom enable debug log of libvirtd.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
8 years agolibvirt-nodedev.c:fix a typo
Nitesh Konkar [Wed, 21 Sep 2016 20:02:52 +0000 (01:32 +0530)]
libvirt-nodedev.c:fix a typo

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
8 years agolibvirt-admin.c:fix a typo
Nitesh Konkar [Wed, 21 Sep 2016 19:31:50 +0000 (01:01 +0530)]
libvirt-admin.c:fix a typo

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
8 years agodriver.c:fix a typo
Nitesh Konkar [Wed, 21 Sep 2016 19:17:30 +0000 (00:47 +0530)]
driver.c:fix a typo

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
8 years agodomain_conf.c:fix the comment.
Nitesh Konkar [Wed, 21 Sep 2016 17:17:30 +0000 (22:47 +0530)]
domain_conf.c:fix the comment.

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
8 years agodomain_conf.c:fix a typo
Nitesh Konkar [Wed, 21 Sep 2016 19:18:48 +0000 (00:48 +0530)]
domain_conf.c:fix a typo

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
8 years agodomain_conf.c:fix a typo
Nitesh Konkar [Wed, 21 Sep 2016 16:52:02 +0000 (22:22 +0530)]
domain_conf.c:fix a typo

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
8 years agomigration: Document we don't copy storage during offline migration
Michal Privoznik [Wed, 21 Sep 2016 09:25:13 +0000 (11:25 +0200)]
migration: Document we don't copy storage during offline migration

https://bugzilla.redhat.com/show_bug.cgi?id=1322717

During offline migration, no storage is copied. Nor disks, nor
NVRAM file, nor anything. We use qemu for that and because domain
is not running there's nobody to copy that for us.
We should document this to avoid confusing users.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu: driver: Don't return automatic NUMA emulator pinning data for persistentDef
Peter Krempa [Wed, 14 Sep 2016 05:37:16 +0000 (07:37 +0200)]
qemu: driver: Don't return automatic NUMA emulator pinning data for persistentDef

Calling virDomainGetEmulatorPinInfo on a live VM with automatic NUMA
pinning and VIR_DOMAIN_AFFECT_CONFIG would return the automatic pinning
data in some cases which is bogus. Use the autoCpuset property only when
called on a live definition.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1365779

8 years agoqemu: driver: Don't return automatic NUMA vCPU pinning data for persistentDef
Peter Krempa [Wed, 14 Sep 2016 05:37:16 +0000 (07:37 +0200)]
qemu: driver: Don't return automatic NUMA vCPU pinning data for persistentDef

Calling virDomainGetVcpuPinInfo on a live VM with automatic NUMA pinning
and VIR_DOMAIN_AFFECT_CONFIG would return the automatic pinning data
in some cases which is bogus. Use the autoCpuset property only when
called on a live definition.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1365779

8 years agoqemu: domain: Add macro to simplify access to vm private data
Peter Krempa [Wed, 14 Sep 2016 05:28:18 +0000 (07:28 +0200)]
qemu: domain: Add macro to simplify access to vm private data

Sometimes adding a separate variable to access vm->privateData is not
necessary. Add a macro that will do the typecasting rather than having
to add a temp variable to force the compiler to typecast it.

8 years agoconf: Introduce virDomainObjGetOneDefState
Peter Krempa [Wed, 14 Sep 2016 05:22:40 +0000 (07:22 +0200)]
conf: Introduce virDomainObjGetOneDefState

Return whether the live or persistent definition was returned. Sometimes
it's necessary to base the decisions on this.

8 years agoqemu: Ignore graphics cookie if port == 0
Jiri Denemark [Tue, 20 Sep 2016 15:27:03 +0000 (17:27 +0200)]
qemu: Ignore graphics cookie if port == 0

Old libvirt represents

    <graphics type='spice'>
      <listen type='none'/>
    </graphics>

as

    <graphics type='spice' autoport='no'/>

In this mode, QEMU doesn't listen for SPICE connection anywhere and
clients have to use virDomainOpenGraphics* APIs to attach to the domain.
That is, the client has to run on the same host where the domains runs
and it's impossible to tell the client to reconnect to the destination
QEMU during migration (unless there is some kind of proxy on the host).

While current libvirt correctly ignores such graphics devices when
creating graphics migration cookie, old libvirt just sends

    <graphics type='spice' port='0' listen='0.0.0.0' tlsPort='-1'/>

in the cookie. After seeing this cookie, we happily would call
client_migrate_info QMP command and wait for SPICE_MIGRATE_COMPLETED
event, which is quite pointless since the doesn't know where to connecti
anyway. We should just ignore such cookies.

https://bugzilla.redhat.com/show_bug.cgi?id=1376083

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemuDomainOpenGraphics: Start job early
Jiri Denemark [Tue, 20 Sep 2016 13:25:06 +0000 (15:25 +0200)]
qemuDomainOpenGraphics: Start job early

Checking if a domain's definition or if it is active before we got a job
is pointless since the domain might have changed in the meantime.

Luckily libvirtd didn't crash when the API tried to talk to an inactive
domain:

debug : qemuDomainObjBeginJobInternal:2914 : Started job: modify
    (async=none vm=0x7f8f340140c0 name=ble)
debug : qemuDomainObjEnterMonitorInternal:3137 : Entering monitor
    (mon=(nil) vm=0x7f8f340140c0 name=ble)
warning : virObjectLock:319 : Object (nil) ((unknown)) is not a
    virObjectLockable instance
debug : qemuMonitorOpenGraphics:3505 : protocol=spice fd=27
    fdname=graphicsfd skipauth=1
error : qemuMonitorOpenGraphics:3508 : invalid argument: monitor must
    not be NULL
debug : qemuDomainObjExitMonitorInternal:3160 : Exited monitor
    (mon=(nil) vm=0x7f8f340140c0 name=ble)
debug : qemuDomainObjEndJob:3068 : Stopping job: modify (async=none
    vm=0x7f8f340140c0 name=ble)

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agostream.c: fix a typo
Nitesh Konkar [Wed, 21 Sep 2016 08:36:09 +0000 (14:06 +0530)]
stream.c: fix a typo

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoconfig-post.h:fix a typo
Nitesh Konkar [Tue, 20 Sep 2016 18:52:15 +0000 (00:22 +0530)]
config-post.h:fix a typo

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
8 years agoqemu: agent: give better error messages whe agent monitor is down
Nikolay Shirokovskiy [Fri, 16 Sep 2016 10:35:36 +0000 (13:35 +0300)]
qemu: agent: give better error messages whe agent monitor is down

We can receive NULL as sync reply in two situations. First
is garbage sync reply and this situation is handled by
resending sync message. Second is different cases
of rebooting guest, destroing domain etc and we can
give more meaningful error message. Actually we have
this error message in qemuAgentCommand already which checks
for the same sitatuion. AFAIK case with mon->running
is just to be safe on adding some future(?) cases of
returning NULL reply.

8 years agoqemu: agent: reissue sync on garbage sync reply
Nikolay Shirokovskiy [Fri, 16 Sep 2016 10:35:35 +0000 (13:35 +0300)]
qemu: agent: reissue sync on garbage sync reply

We can easily handle receiving garbage on sync. We don't
have to make client deal with this situation. We just
need to resend sync command but this time garbage is
not be possible.

8 years agoqemu: agent: skip outdated sync replies
Nikolay Shirokovskiy [Fri, 16 Sep 2016 10:35:34 +0000 (13:35 +0300)]
qemu: agent: skip outdated sync replies

When we wait for sync reply we can receive delayed
reply to syncs or commands that were sent erlier. We can
safely skip them until we receive sync reply with correct id.
There is no much sense report this situation to client.
Actually with a bit of "luck" if we involve client into
this the play can go on forever: send sync 0, receive
sync reply -1, send sync 1, receive reply 0 ...

8 years agoqemu: agent: ignore garbage while waiting for sync reply
Nikolay Shirokovskiy [Fri, 16 Sep 2016 10:35:33 +0000 (13:35 +0300)]
qemu: agent: ignore garbage while waiting for sync reply

After sync is sent we can receive garbare and this is not error.
Consider next regular case:

1. libvirtd sends sync
2. qga sends partial sync reply and die
3. libvirtd sends sync
4. qga sends sync reply
5. libvirtd receives garbage
  (half of first reply and second reply together)

We should handle this situation as it is recoverable.
Next sync can succeed. Let's report reply is NULL,
it will be converted to the VIR_ERR_AGENT_UNSYNCED
which signals client to retry.

8 years agoqemu: agent: ignore delayed reply when unsynced
Nikolay Shirokovskiy [Fri, 16 Sep 2016 10:35:32 +0000 (13:35 +0300)]
qemu: agent: ignore delayed reply when unsynced

Errors in qemuAgentIOProcessLine stop agent IO processing just
like any regular IO error, however some of current errors
that this functions spawns are false positives. Consider
next case for example:

1. send sync (unsynced state)
2. receive sync reply (sync established)
3. command send, but timeout occured (unsynced state)
4. receive command reply

Last IO triggers error because current code ignores
only delayed syncs when unsynced

We should not treat any delayed reply as error in unsynced
state. Until client and qga are not in sync delayed reply to any
command is possible. msg == NULL is the exact criterion
that we are not in sync.

8 years agoconf: Add some shmem helpers for future use
Martin Kletzander [Mon, 12 Sep 2016 11:41:07 +0000 (13:41 +0200)]
conf: Add some shmem helpers for future use

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: Add qemuAssignDeviceShmemAlias and use it
Martin Kletzander [Mon, 12 Sep 2016 13:48:41 +0000 (15:48 +0200)]
qemu: Add qemuAssignDeviceShmemAlias and use it

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: Rename qemuBuildShmemBackendStr to qemuBuildShmemBackendChrStr
Martin Kletzander [Tue, 13 Sep 2016 12:12:29 +0000 (14:12 +0200)]
qemu: Rename qemuBuildShmemBackendStr to qemuBuildShmemBackendChrStr

There will be more backends in the future so let's not complicate it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: Abstract shmem socket path preparation
Martin Kletzander [Tue, 13 Sep 2016 11:40:50 +0000 (13:40 +0200)]
qemu: Abstract shmem socket path preparation

Put it into qemuDomainPrepareShmemChardev() so it can be used later.
Also don't fill in the path unless the server option is enabled.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: Reorder shmem params nicely
Martin Kletzander [Wed, 10 Aug 2016 07:34:45 +0000 (09:34 +0200)]
qemu: Reorder shmem params nicely

Always format id first so that we don't need to do that twice in
different code paths.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: Move common checks outside qemuBuildShmemDevLegacyStr
Martin Kletzander [Mon, 8 Aug 2016 11:44:38 +0000 (13:44 +0200)]
qemu: Move common checks outside qemuBuildShmemDevLegacyStr

Some checks will need to be performed for newer device types as well, so
let's not duplicate them.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: Rename qemuBuildShmemDevStr to qemuBuildShmemDevLegacyStr
Martin Kletzander [Mon, 8 Aug 2016 11:44:28 +0000 (13:44 +0200)]
qemu: Rename qemuBuildShmemDevStr to qemuBuildShmemDevLegacyStr

This will make sense after adding support for newer device types.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: Make qemuBuildShmemDevStr static
Martin Kletzander [Mon, 8 Aug 2016 14:45:37 +0000 (16:45 +0200)]
qemu: Make qemuBuildShmemDevStr static

It isn't used anywhere else.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agovirtlogd: Don't stop or restart along with libvirtd
Andrea Bolognani [Tue, 20 Sep 2016 13:22:04 +0000 (15:22 +0200)]
virtlogd: Don't stop or restart along with libvirtd

Commit 839a060 tied the lifecycle of virtlogd more
closely to that of libvirtd. Unfortunately, while starting
virtlogd when libvirtd is started is definitely a good idea,
restarting virtlogd or shutting it down at any time outside
of system poweroff is not.

Revert part of that commit by removing the PartOf= lines,
meaning that only startup requests will be propagated from
libvirtd to virtlogd.

Resolves: https://bugzilla.redhat.com/1372576

8 years agovirt-admin: Add some command aliases to provide syntax sugar over ugly commands
Erik Skultety [Wed, 7 Sep 2016 15:27:52 +0000 (17:27 +0200)]
virt-admin: Add some command aliases to provide syntax sugar over ugly commands

Make use of the new recently introduced alias handling for virt-admin srv-*
commands.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovirt-admin: Tweak command parsing logic so that aliases point to new commands
Erik Skultety [Wed, 7 Sep 2016 15:30:48 +0000 (17:30 +0200)]
virt-admin: Tweak command parsing logic so that aliases point to new commands

Change the logic in a way, so that VSH_CMD_FLAG_ALIAS behaves similarly to
how VSH_OT_ALIAS for command options, i.e. there is no need for code duplication
for the alias and the aliased command structures. Along with that change,
switch any existing VSH_CMD_FLAG_ALIAS occurrences to this new format. Also,
since this patch introduces a new command structure element, adjust the
virsh-self-test test to make sure we won't ever miss to specify the '.alias'
member for an aliased command because doing that would lead to an internal
error.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovirsh: man: Do not document our old deprecated nodedev-dettach command
Erik Skultety [Fri, 16 Sep 2016 14:06:47 +0000 (16:06 +0200)]
virsh: man: Do not document our old deprecated nodedev-dettach command

The command is deprecated due to being grammatically incorrect, but for
backwards compatibility reasons cannot be removed. However, we should not
document such commands.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovsh: discard vshCmddefOptFill and move its body to vshCmddefOptParse
Erik Skultety [Fri, 16 Sep 2016 08:17:46 +0000 (10:17 +0200)]
vsh: discard vshCmddefOptFill and move its body to vshCmddefOptParse

Recent changes extracted the command internals validation routine from
vshCmddefOptParse method which now just calls vshCmddefOptFill. Therefore, make
vshCmddefOptFill the new vshCmddefOptParse and drop the unnecessary name.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovsh: Extract vshCmddefCheckInternals from vshCmddefOptParse
Erik Skultety [Fri, 16 Sep 2016 07:58:24 +0000 (09:58 +0200)]
vsh: Extract vshCmddefCheckInternals from vshCmddefOptParse

Originally introduced by commit 2432521e which correctly split
vshCmddefOptParse into command's options validation and options parsing.
However, command's 'internals' are not tied solely to .options, rather it
should be about the overall structure, therefore the validation should be
extracted from vshCmddefOptParse and performed only within our test suite, i.e.
in vshSelfTest.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovsh: vshCmddefHelp: Drop the unnecessary 'else' branch
Erik Skultety [Thu, 15 Sep 2016 15:52:11 +0000 (17:52 +0200)]
vsh: vshCmddefHelp: Drop the unnecessary 'else' branch

If the initial check is true the function immediately returns so there's no
need to enclose the code following the check within an 'else' block.
Also, by removing the 'else' block, the declarations need to be moved to
beginning of the function block to conform with our guidelines.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovsh: vshCmddefHelp: Drop unnecessary variable 'help'
Erik Skultety [Fri, 16 Sep 2016 12:32:01 +0000 (14:32 +0200)]
vsh: vshCmddefHelp: Drop unnecessary variable 'help'

Since it's used on a single place only, it can easily be replaced by the right
side of the original assignment.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovsh: Enforce checking for missing help string
Erik Skultety [Mon, 19 Sep 2016 11:10:38 +0000 (13:10 +0200)]
vsh: Enforce checking for missing help string

The intention is to move vshCmddefCheckInternals out of vshCmddefOptParse to
our test suite. First step to do that is to enforce checking for an existing
help string (that also means it's non-empty) in a command because a command
without a help is not much of a use.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoAdd missing 'extern' for VIR_EXPORT_VAR macro
Daniel P. Berrange [Tue, 20 Sep 2016 11:51:07 +0000 (12:51 +0100)]
Add missing 'extern' for VIR_EXPORT_VAR macro

The recent update to gnulib

  commit 9d7a37ecb2ab516c19164a57b8aeb32016a99d2c
  Author: Eric Blake <eblake@redhat.com>
  Date:   Thu Sep 15 15:12:52 2016 -0500

    build: update to latest gnulib

Pulled in a change that adds -fno-common to the default compiler
flags

  commit bf8e658ffadb95d444f56d222d04c9af955af765
  Author: Jim Meyering <meyering@fb.com>
  Date:   Fri Sep 2 09:16:16 2016 -0700

    manywarnings: add -fno-common

This caused libvirt Mingw build to break with the compiler
reporting 100's of definitions of virConnectAuthPtrDefault

./.libs/libvirt_util.a(libvirt_util_la-virarch.o):virarch.c:(.bss+0x0): multiple definition of `virConnectAuthPtrDefault'
./.libs/libvirt_util.a(libvirt_util_la-viralloc.o):viralloc.c:(.bss+0x0): first defined here
./.libs/libvirt_util.a(libvirt_util_la-viratomic.o):viratomic.c:(.bss+0x0): multiple definition of `virConnectAuthPtrDefault'
./.libs/libvirt_util.a(libvirt_util_la-viralloc.o):/home/berrange/src/virt/libvirt/src/util/viralloc.c:87: first defined here
./.libs/libvirt_util.a(libvirt_util_la-viraudit.o):viraudit.c:(.bss+0x0): multiple definition of `virConnectAuthPtrDefault'
./.libs/libvirt_util.a(libvirt_util_la-viralloc.o):/home/berrange/src/virt/libvirt/src/util/viralloc.c:87: first defined here
./.libs/libvirt_util.a(libvirt_util_la-virauth.o):virauth.c:(.bss+0x0): multiple definition of `virConnectAuthPtrDefault'
./.libs/libvirt_util.a(libvirt_util_la-viralloc.o):/home/berrange/src/virt/libvirt/src/util/viralloc.c:87: first defined here
./.libs/libvirt_util.a(libvirt_util_la-virauthconfig.o):virauthconfig.c:(.bss+0x0): multiple definition of `virConnectAuthPtrDefault'
...snip...

The cause is our VIR_EXPORT_VAR macro which has some
magic on win to add dllexport/dllimport to the variable
declaration. Unfortunately the dllexport branch missed
off the 'extern' keyword, so the header file was in
fact declaring an instance of the variable in every
source file.

Previously the linker would merge all these definitions
into one, but that no longer happens due to -fno-common

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agotest: update capability replies for qemu-2.7.0
Pavel Hrdina [Tue, 20 Sep 2016 08:42:18 +0000 (10:42 +0200)]
test: update capability replies for qemu-2.7.0

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_process: fix a typo
Chen Hanxiao [Tue, 20 Sep 2016 07:37:21 +0000 (15:37 +0800)]
qemu_process: fix a typo

s/unitl/until

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
8 years agotests: fix use of fixedcontent variable
Laine Stump [Mon, 19 Sep 2016 17:44:21 +0000 (13:44 -0400)]
tests: fix use of fixedcontent variable

Commit 8563560026d192c2cf047b550ffd468692245ed6 switched from
hardcoded use of strcontent to hardcoded use of fixedcontent
(fixedcontent is *sometimes* a copy of strcontent with a \n
appended). This was a problem because sometimes fixedcontent is *not*
a copy of strcontent, but is instead NULL, leading to the regenerated
test case output being a 0 length file.

This patch creates a new const char *cmpcontent initialized to
strcontent, but changed to fixedcontent if/when fixedcontent is
created, then always uses cmpcontent instead of (str|fixed)content.

8 years agoRevert "configure: Check for major() more strictly"
Eric Blake [Thu, 15 Sep 2016 20:13:27 +0000 (15:13 -0500)]
Revert "configure: Check for major() more strictly"

This reverts commit d53fa838e18d8c192296487ff40c3a37420b6d06,
which is no longer needed now that gnulib does the job.

Signed-off-by: Eric Blake <eblake@redhat.com>
8 years agobuild: update to latest gnulib
Eric Blake [Thu, 15 Sep 2016 20:12:52 +0000 (15:12 -0500)]
build: update to latest gnulib

In particular, pull in gnulib's fix for the broken AC_HEADER_MAJOR
macro in autoconf.

Signed-off-by: Eric Blake <eblake@redhat.com>
8 years agoqemu: Introduce qemuGetHupageMemPath
Michal Privoznik [Mon, 19 Sep 2016 05:45:12 +0000 (07:45 +0200)]
qemu: Introduce qemuGetHupageMemPath

Now that we have two same implementations for getting path for
huge pages backed guest memory, lets merge them into one function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuBuildMemoryBackendStr: Don't crash if no hugetlbfs is mounted
Michal Privoznik [Sat, 17 Sep 2016 07:29:11 +0000 (09:29 +0200)]
qemuBuildMemoryBackendStr: Don't crash if no hugetlbfs is mounted

When trying to migrate a huge page enabled guest, I've noticed
the following crash. Apparently, if no specific hugepages are
requested:

  <memoryBacking>
    <hugepages/>
  </memoryBacking>

and there are no hugepages configured on the destination, we try
to dereference a NULL pointer.

Program received signal SIGSEGV, Segmentation fault.
0x00007fcc907fb20e in qemuGetHugepagePath (hugepage=0x0) at qemu/qemu_conf.c:1447
1447        if (virAsprintf(&ret, "%s/libvirt/qemu", hugepage->mnt_dir) < 0)
(gdb) bt
#0  0x00007fcc907fb20e in qemuGetHugepagePath (hugepage=0x0) at qemu/qemu_conf.c:1447
#1  0x00007fcc907fb2f5 in qemuGetDefaultHugepath (hugetlbfs=0x0, nhugetlbfs=0) at qemu/qemu_conf.c:1466
#2  0x00007fcc907b4afa in qemuBuildMemoryBackendStr (size=4194304, pagesize=0, guestNode=0, userNodeset=0x0, autoNodeset=0x0, def=0x7fcc70019070, qemuCaps=0x7fcc70004000, cfg=0x7fcc5c011800, backendType=0x7fcc95087228, backendProps=0x7fcc95087218,
    force=false) at qemu/qemu_command.c:3297
#3  0x00007fcc907b4f91 in qemuBuildMemoryCellBackendStr (def=0x7fcc70019070, qemuCaps=0x7fcc70004000, cfg=0x7fcc5c011800, cell=0, auto_nodeset=0x0, backendStr=0x7fcc70020360) at qemu/qemu_command.c:3413
#4  0x00007fcc907c0406 in qemuBuildNumaArgStr (cfg=0x7fcc5c011800, def=0x7fcc70019070, cmd=0x7fcc700040c0, qemuCaps=0x7fcc70004000, auto_nodeset=0x0) at qemu/qemu_command.c:7470
#5  0x00007fcc907c5fdf in qemuBuildCommandLine (driver=0x7fcc5c07b8a0, logManager=0x7fcc70003c00, def=0x7fcc70019070, monitor_chr=0x7fcc70004bb0, monitor_json=true, qemuCaps=0x7fcc70004000, migrateURI=0x7fcc700199c0 "defer", snapshot=0x0,
    vmop=VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_START, standalone=false, enableFips=false, nodeset=0x0, nnicindexes=0x7fcc95087498, nicindexes=0x7fcc950874a0, domainLibDir=0x7fcc700047c0 "/var/lib/libvirt/qemu/domain-1-fedora") at qemu/qemu_command.c:9547

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu_agent|monitor: use different log on hangup event
Chen Hanxiao [Mon, 19 Sep 2016 06:24:50 +0000 (14:24 +0800)]
qemu_agent|monitor: use different log on hangup event

Both qemu monitor and agent print the same
log on HUANGUP event, which would be confusing
when reading libvirtd log.

This patch will give a different log message to them.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
8 years agodocs: expand docs on user x509 cert locations
Daniel P. Berrange [Thu, 15 Sep 2016 13:47:59 +0000 (14:47 +0100)]
docs: expand docs on user x509 cert locations

The layout in $HOME/.pki is different from that in /etc/pki
but we never tell anyone about this trap. Add docs showing
the required $HOME/.pki layout.

8 years agoconf: Allow copying of shmem defs
Martin Kletzander [Thu, 15 Sep 2016 15:14:31 +0000 (17:14 +0200)]
conf: Allow copying of shmem defs

This way we'll be able to hotplug with both --live and --config in one
API call.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoschema: Allow shmem to have alias
Martin Kletzander [Thu, 15 Sep 2016 08:33:06 +0000 (10:33 +0200)]
schema: Allow shmem to have alias

It already is used and tests will be automatically added in later patches.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemuhotplugtest: Only read result_filename if used
Martin Kletzander [Thu, 15 Sep 2016 08:58:17 +0000 (10:58 +0200)]
qemuhotplugtest: Only read result_filename if used

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: map "virtio" video model to "virt" machtype correctly (arm/aarch64)
Laszlo Ersek [Fri, 16 Sep 2016 07:30:23 +0000 (09:30 +0200)]
qemu: map "virtio" video model to "virt" machtype correctly (arm/aarch64)

Most of QEMU's PCI display device models, such as:

  libvirt video/model/@type  QEMU -device
  -------------------------  ------------
  cirrus                     cirrus-vga
  vga                        VGA
  qxl                        qxl-vga
  virtio                     virtio-vga

come with a linear framebuffer (sometimes called "VGA compatibility
framebuffer"). This linear framebuffer lives in one of the PCI device's
MMIO BARs, and allows guest code (primarily: firmware drivers, and
non-accelerated OS drivers) to display graphics with direct memory access.

Due to architectural reasons on aarch64/KVM hosts, this kind of
framebuffer doesn't / can't work in

  qemu-system-(arm|aarch64) -M virt

machines. Cache coherency issues guarantee a corrupted / unusable display.
The problem has been researched by several people, including kvm-arm
maintainers, and it's been decided that the best way (practically the only
way) to have boot time graphics for such guests is to consolidate on
QEMU's "virtio-gpu-pci" device.

>From <https://bugzilla.redhat.com/show_bug.cgi?id=1195176>, libvirt
supports

  <devices>
    <video>
      <model type='virtio'/>
    </video>
  </devices>

but libvirt unconditionally maps @type='virtio' to QEMU's "virtio-vga"
device model. (See the qemuBuildDeviceVideoStr() function and the
"qemuDeviceVideo" enum impl.)

According to the above, this is not right for the "virt" machine type; the
qemu-system-(arm|aarch64) binaries don't even recognize the "virtio-vga"
device model (justifiedly). Whereas "virtio-gpu-pci", which is a pure
virtio device without a compatibility framebuffer, is available, and works
fine.

(The ArmVirtQemu ("AAVMF") platform of edk2 -- that is, the UEFI firmware
for "virt" -- supports "virtio-gpu-pci", as of upstream commit
3ef3209d3028. See
<https://tianocore.acgmultimedia.com/show_bug.cgi?id=66>.)

Override the default mapping of "virtio", from "virtio-vga" to
"virtio-gpu-pci", if qemuDomainMachineIsVirt() evaluates to true.

Cc: Andrea Bolognani <abologna@redhat.com>
Cc: Drew Jones <drjones@redhat.com>
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Cc: Martin Kletzander <mkletzan@redhat.com>
Suggested-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1372901
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoutil: Expose virHostCPUStatsAssign on non-Linux
Martin Kletzander [Fri, 16 Sep 2016 06:33:47 +0000 (08:33 +0200)]
util: Expose virHostCPUStatsAssign on non-Linux

There is nothing Linux-specific in that function.  Also since commit
8c3b5bf48123783b812b97360db7ac51f1889e17 mingw build is broken due to
the fact that this function is not compiled in the library.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agotest driver: Implement testNodeGetFreePages.
Tomáš Ryšavý [Thu, 15 Sep 2016 08:27:09 +0000 (10:27 +0200)]
test driver: Implement testNodeGetFreePages.

Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
8 years agotest driver: added pages sizes into XML into test driver.
Tomáš Ryšavý [Thu, 15 Sep 2016 08:27:08 +0000 (10:27 +0200)]
test driver: added pages sizes into XML into test driver.

Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
8 years agotest driver: Implement testNodeGetFreeMemory
Tomáš Ryšavý [Thu, 15 Sep 2016 08:27:07 +0000 (10:27 +0200)]
test driver: Implement testNodeGetFreeMemory

Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agotest driver: Implement testNodeGetCPUStats
Tomáš Ryšavý [Thu, 15 Sep 2016 08:27:06 +0000 (10:27 +0200)]
test driver: Implement testNodeGetCPUStats

Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agotest driver: Implement virConnectGetType.
Tomáš Ryšavý [Thu, 15 Sep 2016 08:27:05 +0000 (10:27 +0200)]
test driver: Implement virConnectGetType.

Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agotest driver: Implement virConnectGetSysinfo.
Tomáš Ryšavý [Thu, 15 Sep 2016 08:27:04 +0000 (10:27 +0200)]
test driver: Implement virConnectGetSysinfo.

Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agotest_driver: Replace magic constant
Tomáš Ryšavý [Thu, 15 Sep 2016 08:27:03 +0000 (10:27 +0200)]
test_driver: Replace magic constant

In testOpenDefault we create a virtual computer that is later
presented to user. We also pretend to have NUMA cells and
initialize them somehow. But whilst doing so a magical constant
is used. Drop it.

Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirhostcpu: Expose virHostCPUStatsAssign
Tomáš Ryšavý [Thu, 15 Sep 2016 08:27:02 +0000 (10:27 +0200)]
virhostcpu: Expose virHostCPUStatsAssign

We will need this function shortly when implementing
nodeGetCPUStats in the test driver.

Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirsh: use virConnectGetDomainCapabilities with maxvcpus
Shivaprasad G Bhat [Wed, 7 Sep 2016 08:55:42 +0000 (14:25 +0530)]
virsh: use virConnectGetDomainCapabilities with maxvcpus

virsh maxvcpus --type kvm output is useless on PPC. Also, in
commit e6806d79 we documented not rely on virConnectGetMaxVcpus
output. Fix the  maxvcpus to use virConnectGetDomainCapabilities
now to make it useful. The call is made to use the default emulator
binary and to check for the host machine and arch which is what the
command intends to show anyway.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
8 years agotests: Use fixedcontent variable
Martin Kletzander [Tue, 13 Sep 2016 10:49:56 +0000 (12:49 +0200)]
tests: Use fixedcontent variable

Commit ca32929908bbc94116493ad8915e7cd7ae0f57d5 added function
virTestCompareToFile(), but forgot to use a fixedcontent value for the
actual comparison.  That lead to VIR_TEST_DEBUG=1 showing (for some
tests) all the actual output from the first error to the end of the
string due to the difference being an endline in the end.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agohyperv: additional server 2008 wmi classes
Jason Miesionczek [Tue, 9 Aug 2016 12:39:09 +0000 (12:39 +0000)]
hyperv: additional server 2008 wmi classes

8 years agotests: Self test virt-admin
Michal Privoznik [Wed, 14 Sep 2016 08:08:48 +0000 (10:08 +0200)]
tests: Self test virt-admin

Just like we are running 'virsh self-test' from within our test
suite, we should run 'virt-admin self-test' too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirsh: Move cmdSelfTest to vsh
Michal Privoznik [Wed, 14 Sep 2016 07:50:22 +0000 (09:50 +0200)]
virsh: Move cmdSelfTest to vsh

This command should be exposed to other shells of ours.
They are gonna need it as soon as we want to test them too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu: domain: Don't infer vcpu state
Peter Krempa [Tue, 13 Sep 2016 15:56:08 +0000 (17:56 +0200)]
qemu: domain: Don't infer vcpu state

Use the state information (online, hotpluggable) provided by the monitor
code rather than trying to infer it. This fixes an issue where on
architectures that require hotplug of multiple threads at once the
sub-cores would get updated as offline on daemon restart thus creating
an invalid configuration.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1375783

8 years agoqemu: monitor: Add vcpu state information to monitor data
Peter Krempa [Tue, 13 Sep 2016 15:52:38 +0000 (17:52 +0200)]
qemu: monitor: Add vcpu state information to monitor data

Return whether a vcpu entry is hotpluggable or online so that upper
layers don't have to infer the information from other data.

Advantage is that this code can be tested by unit tests.

8 years agoqemu: monitor: qemuMonitorGetCPUInfoHotplug: Add iterator 'anycpu'
Peter Krempa [Tue, 13 Sep 2016 15:38:08 +0000 (17:38 +0200)]
qemu: monitor: qemuMonitorGetCPUInfoHotplug: Add iterator 'anycpu'

Add separate iterator for iterating all the entries

8 years agoqemu: monitor: Use a more obvious iterator name
Peter Krempa [Tue, 13 Sep 2016 15:28:02 +0000 (17:28 +0200)]
qemu: monitor: Use a more obvious iterator name

The algorithm that matches data from query-cpus and
query-hotpluggable-cpus is quite complex. Start using descriptive
iterator names to avoid confusion.

8 years agovirDomainGetBlockJobInfo: Fix corner case when qemu reports no info
Michal Privoznik [Fri, 2 Sep 2016 07:45:44 +0000 (09:45 +0200)]
virDomainGetBlockJobInfo: Fix corner case when qemu reports no info

https://bugzilla.redhat.com/show_bug.cgi?id=1372613

Apparently, some management applications use the following code
pattern when waiting for a block job to finish:

  while (1) {
    virDomainGetBlockJobInfo(dom, disk, info, flags);

    if (info.cur == info.end)
        break;

    sleep(1);
  }

Problem with this approach is in its corner cases. In case of
QEMU, libvirt merely pass what has been reported on the monitor.
However, if the block job hasn't started yet, qemu reports cur ==
end == 0 which tricks mgmt apps into thinking job is complete.

The solution is to mangle cur/end values as described here [1].

1: https://www.redhat.com/archives/libvir-list/2016-September/msg00017.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>