Commit Graph

5262 Commits

Author SHA1 Message Date
Cole Robinson
ef2c82170f qemu: alias: Remove QEMU_CAPS_DEVICE
QEMU_CAPS_DEVICE is always set nowadays, so drop code that depends
on not-DEVICE
2016-05-16 10:29:39 -04:00
Cole Robinson
c7d6c13989 qemu: command: Ignore QEMU_CAPS_DEVICE when building drive alias
QEMU_CAPS_DEVICE is always set nowadays, so we can drop the
non-DEVICE code paths
2016-05-16 08:59:35 -04:00
John Ferlan
abd2272c02 secret: Alter virSecretGetSecretString
Rather than returning a "char *" indicating perhaps some sized set of
characters that is NUL terminated, alter the function to return 0 or -1
for success/failure and add two parameters to handle returning the
buffer and it's size.

The function no longer encodes the returned secret, rather it returns
the unencoded secret forcing callers to make the necessary adjustments.

Alter the callers to handle the adjusted model.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-05-16 12:58:48 +02:00
Peter Krempa
fb1dddfb00 qemu: domain: Fix names for functions that clear security info
They don't free the structure itself so they should be called *Clear
rather than *Free.
2016-05-16 12:58:48 +02:00
Peter Krempa
cb2e3e50ee util: string: Introduce virStringEncodeBase64
Add a new helper that sanitizes error semantics of base64_encode_alloc.
2016-05-16 12:58:48 +02:00
Peter Krempa
1d632c3924 secret: util: Refactor virSecretGetSecretString
Call the internal driver callbacks rather than the public APIs to avoid
calling unnecessarily the error dispatching code and don't overwrite
the error messages provided by the APIs. They are good enough to
describe which secret is missing either by UUID or the usage (basically
name).
2016-05-16 12:58:48 +02:00
Jiri Denemark
ced1e846a0 capabilities: Advertise cpuselection if -cpu host is usable
When -cpu host is supported by a QEMU binary, a user can use
<cpu mode='host-passthrough'/> in domain XML even when libvirtd failed
to find a matching model for the host CPU. Let's make it obvious by
advertising <cpuselection/> guest capability whenever -cpu host is
supported.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-05-16 10:42:28 +02:00
Fabian Freyer
9055faebd4 qemu: remove ATTRIBUTE_UNUSED in connectGetType
This is not needed here, since the conn parameter is used in the ACL
checking calls, which were introduced in abf75aea2.
2016-05-13 15:52:11 -04:00
Shivaprasad G Bhat
be1a7e6d31 leave out the default USB controller only on i440fx during migration
Further followup discussions in list on commit 192a53e concluded
that we should be leaving out the USB controller only for
i440fx machines as default USB can be used by someone on q35
at random slots.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
2016-05-13 10:11:00 +02:00
Peter Krempa
2a1a9808b1 qemu: domain: Fix name of macro defining AES IV length
The initialization vector is a technical term by itself different from
the key.
2016-05-12 17:13:09 +02:00
John Ferlan
677b94f487 qemu: Change from SecretIV or _IV to SecretAES or _AES
The preferred name will be AES not IV, change current references

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-05-12 09:30:08 -04:00
Ján Tomko
538012c8a3 Fill out default vram in DeviceDefPostParse
Move filling out the default video (v)ram to DeviceDefPostParse.

This means it can be removed from virDomainVideoDefParseXML
and qemuParseCommandLine. Also, we no longer need to special case
VIR_DOMAIN_VIRT_XEN, since the per-driver callback gets called
before the generic one.
2016-05-12 08:22:08 +02:00
Laine Stump
e5aecc2f80 conf: log error when incorrect PCI root controller is added to domain
libvirt may automatically add a pci-root or pcie-root controller to a
domain, depending on the arch/machinetype, and it hopefully always
makes the right decision about which to add (since in all cases these
controllers are an implicit part of the virtual machine).

But it's always possible that someone will create a config that
explicitly supplies the wrong type of PCI controller for the selected
machinetype. In the past that would lead to an error later when
libvirt was trying to assign addresses to other devices, for example:

  XML error: PCI bus is not compatible with the device at
  0000:00:02.0. Device requires a PCI Express slot, which is not
  provided by bus 0000:00

(that's the error message that appears if you replace the pcie-root
controller in a Q35 domain with a pci-root controller).

This patch adds a check at the same place that the implicit
controllers are added (to ensure that the same logic is used to check
which type of pci root is correct). If a pci controller with index='0'
is already present, we verify that it is of the model that we would
have otherwise added automatically; if not, an error is logged:

  The PCI controller with index='0' must be " model='pcie-root' for
  this machine type, " but model='pci-root' was found instead.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1004602
2016-05-10 17:03:24 -04:00
John Ferlan
fc5c1e7fe9 qemu: Add extra checks for secret destroy API's
Remove the possibility that a NULL hostdev->privateData or a
disk->privateData could crash libvirtd by checking for NULL
before dereferencing for the secinfo structure in the
qemuDomainSecret{Disk|Hostdev}Destroy functions. The hostdevPriv
could be NULL if qemuProcessNetworkPrepareDevices adds a new
hostdev during virDomainNetGetActualHostdev that then gets
inserted via virDomainHostdevInsert. The hostdevPriv was added
by commit id '27726d8' and is currently only used by scsi hostdev.
2016-05-10 15:48:08 -04:00
Laine Stump
75db9997a0 util: set vlan tag for macvtap passthrough mode on SRIOV VFs
SRIOV VFs used in macvtap passthrough mode can take advantage of the
SRIOV card's transparent vlan tagging. All the code was there to set
the vlan tag, and it has been used for SRIOV VFs used for hostdev
interfaces for several years, but for some reason, the vlan tag for
macvtap passthrough devices was stubbed out with a -1.

This patch moves a bit of common validation down to a lower level
(virNetDevReplaceNetConfig()) so it is shared by hostdev and macvtap
modes, and updates the macvtap caller to actually send the vlan config
instead of -1.
2016-05-10 14:04:19 -04:00
Pavel Hrdina
1ccc7fbff3 qemu_hotplug: fix checking graphics ports
We cannot change ports for running domain and we should error out if
autoport is enabled.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-05-10 10:44:46 +02:00
Pavel Hrdina
9d88cbea87 qemu_process: merge graphics code into qemuProcessSetupGraphics
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-05-10 10:44:45 +02:00
Pavel Hrdina
9f51c1c7c7 graphics: generate fake ports also for tests
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-05-10 10:44:45 +02:00
Pavel Hrdina
446aebbcf6 qemu_process: separate graphics port reservation
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-05-10 10:44:45 +02:00
Cole Robinson
f0187c1f27 qemu: command: unconditionally allow accel3d='no'
This matches how we handle spice gl='no' even if spice GL isn't
supported. Not too interesting in practice but I figure we should
be consistent
2016-05-09 16:06:32 -04:00
Cole Robinson
5ed235c68f domaincaps: Report video modelType
Requires adding the plumbing for <device><video>
The value is <enum name='modelType'> to match the associated domain
XML of <video><model type='XXX'/>

Wire it up for qemu too
2016-05-09 16:05:31 -04:00
Cole Robinson
6da27ad1b5 domaincaps: Report graphics type enum
Requires adding the plumbing for <device><graphics>
Wire it up for qemu too
2016-05-09 16:05:31 -04:00
Peter Krempa
a391a9c5b1 qemu: domain: Don't treat unknown storage type as not having backing chain
qemuDomainCheckDiskPresence has short-circuit code to skip the
determination of the disk backing chain for storage formats that can't
have backing volumes. The code treats VIR_STORAGE_FILE_NONE as not
having backing chain and skips the call to qemuDomainDetermineDiskChain.

This is wrong as qemuDomainDetermineDiskChain is responsible for storage
format detection and has logic to determine the default type if format
detection is disabled.

This allows to storage passed via <disk type="volume"> to circumvent the
enforcement to have correct storage format or that we shall default to
format='raw', since we don't set the default type via the post parse
callback for "volume" backed disks as the translation code could come up
with a better guess.

This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1328003
2016-05-09 13:40:17 +02:00
Peter Krempa
bd9d707894 qemu: Reject invalid block copy targets for <disk device='lun'>
Extract the relevant parts of the existing checker and reuse them for
blockcopy since copying to a non-block device creates an invalid
configuration.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1209802
2016-05-09 13:16:26 +02:00
Peter Krempa
b66664ffcc qemu: command: Remove unnecessary label in qemuCheckDiskConfig 2016-05-09 13:16:26 +02:00
Peter Krempa
c240335b88 qemu: command: Use more appropriate checking function for block devices
In qemuCheckDiskConfig would now use virDomainDiskSourceIsBlockType just
as a glorified version of virStorageSourceIsBlockLocal that reports
error messages. Replace it with the latter including the message for
clarity.
2016-05-09 13:16:26 +02:00
Peter Krempa
82ba41108a qemu: Support <disk device='lun'> for iSCSI direct mapped volumes
Commit c820fbff9f added support for iSCSI
disk as backing for <disk device='lun'>. We would not use it for a disk
type="volume" with direct access mode which basically maps to direct
iSCSI usage. Fix it by adding the storage source type accessor that
resolves the volume type.
2016-05-09 13:16:26 +02:00
Peter Krempa
3ec7bb354a util: Replace virDomainDiskSourceIsBlockType with a new helper
For disks sources described by a libvirt volume we don't need to do a
complicated check since virStorageTranslateDiskSourcePool already
correctly determines the actual disk type.

Replace the checks using a new accessor that does not open-code the
whole logic.
2016-05-09 12:36:52 +02:00
Michal Privoznik
e85d3e1bbe qemu_monitor_json: Follow refactor
In 7884d089d2 I've started to refactor qemu_monitor_json.c.
Thing is, it's current structure is nothing like the rest of our
code. The @ret variable is rewritten all the time, if()-s are
nested instead of using goto and so on.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-05-09 09:55:18 +02:00
Pavel Hrdina
351ee40643 qemu_hotplug: cleanup error messages in qemuDomainChangeGraphics
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-05-06 15:24:35 +02:00
Pavel Hrdina
39f78671ce qemu_process: handle port allocation for VNC the same way as for Spice
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-05-06 14:54:13 +02:00
Pavel Hrdina
df73f1db82 qemu_process: move listen code out of qemuProcessSetupGraphics
Move adding the config listen type=address if there is none in
qemuProcessPrepareDomain and move check for multiple listens to
qemuProcessStartValidate.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-05-06 14:52:40 +02:00
Pavel Hrdina
76ee92562e graphics: use enums instead of int
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-05-06 14:33:48 +02:00
Jiri Denemark
3af432199d qemu: Export caps cache APIs for tests
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-05-06 10:27:32 +02:00
Jiri Denemark
dccb2629c3 qemu: Separate formatting from saving into caps cache
We will need to use the formatter directly for testing QEMU capabilities
code.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-05-06 10:27:28 +02:00
John Ferlan
bead05ea4d qemu: Introduce qemuDomainSecretIV
Add the data structure and infrastructure to support an initialization
vector (IV) secrets. The IV secret generation will need to have access
to the domain private master key, so let's make sure the prepare disk
and hostdev functions can accept that now.

Anywhere that needs to make a decision over which secret type to use
in order to fill in or use the IV secret has a switch added.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-05-05 14:47:51 -04:00
John Ferlan
2ba52ce095 qemu: Separate network URI command building code
Create helper API's in order to build the network URI as shortly we will
be adding a new SecretInfo type

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-05-05 14:47:51 -04:00
John Ferlan
8ac3b74ad2 qemu: Move qemuDomainSecretDestroy to qemuProcessLaunch
Rather than need to call qemuDomainSecretDestroy after any call to
qemuProcessLaunch, let's do the destroy in qemuProcessLaunch since
that's where command line is eventually generated and processed. Once
it's generated, we can clear out the secrets.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-05-05 14:47:51 -04:00
John Ferlan
3619be4971 qemu: Move qemuDomainSecretPrepare to qemuProcessPrepareDomain
Commit id '40d8e2ba3' added the function to qemuProcessStart because
in order to set up some secrets in the future we will need the master
key. However, since the previous patch split the master key creation
into two parts (create just the key and create the file), we can now
call qemuDomainSecretPrepare from qemuProcessPrepareDomain since the
file is not necessary.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-05-05 14:47:50 -04:00
John Ferlan
608dfc6af0 qemu: Split out the master key create and write
A recent review of related changes noted that we should split the creation
(or generation) of the master key into the qemuProcessPrepareDomain and leave
the writing of the master key for qemuProcessPrepareHost.

Made the adjustment and modified some comments to functions that have
changed calling parameters, but didn't change the intro doc.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-05-05 14:47:50 -04:00
John Ferlan
70ae856e34 qemu: Adjust names of qemuDomainSecretInfoType enums
From a review after push, add the "_TYPE" into the name.

Also use qemuDomainSecretInfoType in the struct rather than int
with the comment field containing the struct name

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-05-05 14:47:50 -04:00
Jiri Denemark
666d780531 qemu: Make qemuMonitorJSONIOProcessLine available for tests
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-05-05 10:01:55 +02:00
Jiri Denemark
b0b8517eeb qemu: Make virQEMUCapsNewForBinary usable from tests
virQEMUCapsNewForBinary unconditionally loads data from cache and probes
using both QMP and -help parsing, which is suboptimal when we want to
use it in tests.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-05-05 10:01:55 +02:00
John Ferlan
d0b5845952 qemu: Add 'iothread' to command line for supported controller
https://bugzilla.redhat.com/show_bug.cgi?id=1286709

Now that we have all the pieces in place, we can add the 'iothread=#' to
the command line for the (two) controllers that support it (virtio-scsi-pci
and virtio-scsi-ccw). Add the tests as well...
2016-05-04 09:59:14 -04:00
John Ferlan
ade5dae282 qemu: Use switch for qemuCheckIOThreads
Rather than an if statement, use a switch.

The switch will also catch the illegal usage of 'iothread' with some other
kind of unsupported bus configuration.
2016-05-04 09:59:14 -04:00
John Ferlan
e2faa97672 qemu: Add capability for virtio-scsi iothreads
An iothread for virtio-scsi is a property of the controller. Add a lookup
of the 'virtio-scsi-pci' and 'virtio-scsi-ccw' device properties and parse
the output.  For both, support for the iothread was added in qemu 2.4
while support for virtio-scsi in general was added in qemu 1.4.

Modify the various mock capabilities replies (by hand) to reflect the
when virtio-scsi was supported and then specifically when the iothread
property was added. For versions prior to 1.4, use the no device error
return for virtio-scsi. For versions 1.4 to before 2.4, add some data
for virtio-scsi-pci even though it isn't complete we're not looking for
anything specific there anyway. For 2.4 to 2.6, add a more complete reply.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-05-03 14:08:05 -04:00
Michal Privoznik
7884d089d2 qemu_monitor_json: Follow our coding style
In majority of our functions we have this variable @ret that is
overwritten a lot. In other areas of the code we use 'goto
cleanup;' just so that this wouldn't happen. But here.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-05-03 15:45:44 +02:00
Cole Robinson
600977e293 qemu: support configuring usb3 controller port count
This adds a ports= attribute to usb controller XML, like

  <controller type='usb' model='nec-xhci' ports='8'/>

This maps to:

  qemu -device nec-usb-xhci,p2=8,p3=8

Meaning, 8 ports that support both usb2 and usb3 devices. Gerd
suggested to just expose them as one knob.

https://bugzilla.redhat.com/show_bug.cgi?id=1271408
2016-05-03 08:58:30 -04:00
Cole Robinson
48e12de51e qemu: caps: introduce QEMU_CAPS_NEC_USB_XHCI_PORTS
Reports whether we support -device nec-usb-xhci,p3=XXX value,
which has been available since qemu 1.3.0
2016-05-03 08:58:30 -04:00
Cole Robinson
345d2ab488 qemu: parse: Use virControllerDefNew
Rather than reimplement it. This will be needed in upcoming patches
2016-05-03 08:58:30 -04:00
Michal Privoznik
e2ac519cd2 qemu_monitor_json: Drop redundant checks
In these functions I'm fixing here, we do call
qemuMonitorJSONCheckError() followed by another check if qemu
reply contains 'return' object. If it wouldn't, the former
CheckError() function would error out and the flow would not even
get to the latter.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-05-03 14:18:02 +02:00
Michal Privoznik
3af8186898 qemuMonitorJSONQueryRxFilter: Validate qemu reply prior parsing it
Usually, the flow in this area of the code is as follows:

qemuMonitorJSONMakeCommand()
qemuMonitorJSONCommand()
qemuMonitorJSONCheckError()
parseReply()

But in this function, for some reasons, the last two steps were
swapped. This makes no sense.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-05-03 14:18:02 +02:00
Ján Tomko
f2b157945f Remove useless os.machine NULL check
In qemuDomainDefAddDefaultDevices we check for a non-NULL
def->os.machine for x86 archs, but not the others.

Moreover, the only caller - qemuDomainDefPostParse
already checks for it and even then it can happen only
if /etc/libvirt contains an XML without a machine type.
2016-05-03 12:29:26 +02:00
Ján Tomko
53a868f152 Introduce qemuDomainMachineIsVirt
Use it everywhere except for virQEMUCapsFillDomainFeatureGICCaps.
2016-05-03 12:08:44 +02:00
Ján Tomko
204b459c1a Rewrite the condition in qemuDomainAssignARMVirtioMMIOAddresses
It was not indented correctly.
2016-05-03 12:08:09 +02:00
Ján Tomko
2d61934a21 Remove useless variable in qemuDomainAssignAddresses
We do not need to propagate the exact return values
and the only possible ones are 0 and -1 anyway.

Remove the temporary variable and use the usual pattern:

if (f() < 0)
    return -1;
2016-05-03 12:07:46 +02:00
Ján Tomko
7c6733a234 Return void in qemuDomainAssignARMVirtioMMIOAddresses
This function does not fail and it does not need to return anything.
2016-05-03 12:07:46 +02:00
Ján Tomko
ef0f90d1b8 Invert condition in qemuDomainDefAddDefaultDevices
For all the other machine types, we use a positive condition.

Be more positive and use it for i440fx too.
2016-05-03 12:07:46 +02:00
Ján Tomko
90f27f07ed Use qemuDomainMachineIs helpers when adding default devices
Do not duplicate the string comparisons by writing them twice.
2016-05-03 12:07:45 +02:00
Michal Privoznik
6ee78d334a qemu: Refresh RTC adjustment on qemuProcessReconnect
https://bugzilla.redhat.com/show_bug.cgi?id=1139766

Thing is, for some reasons you can have your domain's RTC to be
in something different than UTC. More weirdly, it's not only time
zone what you can shift it of, but an arbitrary value. So, if
domain is configured that way, libvirt will correctly put it onto
qemu cmd line and moreover track it as this offset changes during
domain's life time (e.g. because guest OS decides the best thing
to do is set new time to RTC). Anyway, they way in which this
tracking is implemented is events. But we've got a problem if
change in guest's RTC occurs and the daemon is not running. The
event is lost and we end up reporting invalid value in domain
XML. Therefore, when the daemon is starting up again and it is
reconnecting to all running domains, re-fetch their RTC so the
correct offset value can be computed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-05-03 11:44:13 +02:00
Michal Privoznik
b1e2f2d84d qemu: Introduce qemuMonitorGetRTCTime
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-05-03 11:44:13 +02:00
Boris Fiuczynski
73e4e10e62 qemu: add default panic device to S390 guests
This patch adds by default a panic device with model s390 to S390 guests.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2016-05-02 17:01:40 +02:00
Boris Fiuczynski
d855465452 qemu: add panic device support for S390
If a panic device is being defined without a model in a domain
the default value is always overwritten with model ISA. An ISA
bus does not exist on S390 and therefore specifying a panic device
results in an unsupported configuration.
Since the S390 architecture inherently provides a crash detection
capability the panic device should be defined in the domain xml.

This patch adds an s390 panic device model and prevents setting a
device address on it.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
2016-05-02 17:01:40 +02:00
Boris Fiuczynski
b43ab240c2 qemu: merge S390 and S390X default device creation
Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2016-05-02 17:01:40 +02:00
Boris Fiuczynski
a1574e5c98 qemu: fix error message for default panic device
Adding the default bus type ISA to the message.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2016-05-02 17:01:40 +02:00
Shivaprasad G Bhat
192a53e07c send default USB controller in xml to destination during migration
The default USB controller is not sent to destination as the older versions
of libvirt(0.9.4 or earlier as I see in commit log of 409b5f54) didn't
support them. For some archs where the support started much later can
safely send the USB controllers without this worry. So, send the controller
to destination for all archs except x86. Moreover this is not very applicable
to x86 as the USB controller has model ich9_ehci1 on q35 and for pc-i440fx,
there cant be any slots before USB as it is fixed on slot 1.

The patch fixes a bug that, if the USB controller happens to occupy
a slot after disks/interfaces and one of them is hot-unplugged, then
the default USB controller added on destination takes the smallest slot
number and that would lead to savestate mismatch and migration
failure. Seen and verified on PPC64.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
2016-05-02 10:06:04 -04:00
Martin Kletzander
c36b1f7b6a Change virDevicePCIAddress to virPCIDeviceAddress
We had both and the only difference was that the latter also included
information about multifunction setting.  The problem with that was that
we couldn't use functions made for only one of the structs (e.g.
parsing).  To consolidate those two structs, use the one in virpci.h,
include that in domain_conf.h and add the multifunction member in it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-05-02 15:46:23 +02:00
John Ferlan
573cfd188c qemu: hotplug: Fix possible memory leak of props
If we failed to build the aliases or attach the chardev, then the props
would be leaked - fix that.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-05-02 06:29:21 -04:00
John Ferlan
3e81b98ceb qemu: hotplug: Adjust error path for attach hostdev scsi disk
Adjust error path logic to make it clearer how to undo the failed add.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-05-02 06:29:21 -04:00
John Ferlan
843ae77896 qemu: hotplug: Adjust error path for attach virtio disk
Adjust error path logic to make it clearer how to undo the failed add.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-05-02 06:29:21 -04:00
John Ferlan
b0e002fcfd qemu: hotplug: Adjust error path for attach scsi disk
Adjust error path logic to make it clearer how to undo the failed add.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-05-02 06:22:56 -04:00
John Ferlan
db5b47fd4a qemu: Use qemuDomainSecretInfoPtr in qemuBuildNetworkDriveURI
Rather than take username and password as parameters, now take
a qemuDomainSecretInfoPtr and decode within the function.

NB: Having secinfo implies having the username for a plain type
    from a successful virSecretGetSecretString

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-05-02 06:10:19 -04:00
John Ferlan
d081665045 qemu: Introduce qemuDomainSecretHostdevPrepare and Destroy
Similar to the qemuDomainSecretDiskPrepare, generate the secret
for the Hostdev's prior to call qemuProcessLaunch which calls
qemuBuildCommandLine. Additionally, since the secret is not longer
added as part of building the command, the hotplug code will need
to make the call to add the secret in the hostdevPriv.

Since this then is the last requirement to pass a virConnectPtr
to qemuBuildCommandLine, we now can remove that as part of these
changes. That removal has cascading effects through various callers.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-05-02 06:10:19 -04:00
John Ferlan
27726d8c21 qemu: Introduce qemuDomainHostdevPrivatePtr
Modeled after the qemuDomainDiskPrivatePtr logic, create a privateData
pointer in the _virDomainHostdevDef to allow storage of private data
for a hypervisor in order to at least temporarily store auth/secrets
data for usage during qemuBuildCommandLine.

NB: Since the qemu_parse_command (qemuParseCommandLine) code is not
expecting to restore the auth/secret data, there's no need to add
code to handle this new structure there.

Updated copyrights for modules touched. Some didn't have updates in a
couple years even though changes have been made.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-05-02 06:10:19 -04:00
John Ferlan
40d8e2ba37 qemu: Introduce qemuDomainSecretPrepare and Destroy
Rather than needing to pass the conn parameter to various command
line building API's, add qemuDomainSecretPrepare just prior to the
qemuProcessLaunch which calls qemuBuilCommandLine. The function
must be called after qemuProcessPrepareHost since it's expected
to eventually need the domain masterKey generated during the prepare
host call. Additionally, future patches may require device aliases
(assigned during the prepare domain call) in order to associate
the secret objects.

The qemuDomainSecretDestroy is called after the qemuProcessLaunch
finishes in order to clear and free memory used by the secrets
that were recently prepared, so they are not kept around in memory
too long.

Placing the setup here is beneficial for future patches which will
need the domain masterKey in order to generate an encrypted secret
along with an initialization vector to be saved and passed (since
the masterKey shouldn't be passed around).

Finally, since the secret is not added during command line build,
the hotplug code will need to get the secret into the private disk data.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-05-02 06:10:19 -04:00
John Ferlan
48f56a9c5a qemu: Introduce qemuDomainSecretInfo
Introduce a new private structure to hold qemu domain auth/secret data.
This will be stored in the qemuDomainDiskPrivate as a means to store the
auth and fetched secret data rather than generating during building of
the command line.

The initial changes will handle the current username and secret values
for rbd and iscsi disks (in their various forms). The rbd secret is
stored as a base64 encoded value, while the iscsi secret is stored as
a plain text value. Future changes will store encoded/encrypted secret
data as well as an initialization vector needed to be given to qemu
in order to decrypt the encoded password along with the domain masterKey.
The inital assumption will be that VIR_DOMAIN_SECRET_INFO_PLAIN is
being used.

Although it's expected that the cleanup of the secret data will be
done immediately after command line generation, reintroduce the object
dispose function qemuDomainDiskPrivateDispose to handle removing
memory associated with the structure for "normal" cleanup paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-05-02 05:55:40 -04:00
Peter Krempa
7434eba7c7 qemu: monitor: Kill legacy PCI hotplug code 2016-05-02 09:12:14 +02:00
Peter Krempa
7212992034 qemu: hotplug: Assume QEMU_CAPS_DEVICE in qemuDomainAttachControllerDevice 2016-05-02 09:12:14 +02:00
Peter Krempa
b956512f6c qemu: hotplug: Assume QEMU_CAPS_DEVICE in qemuDomainDetachNetDevice 2016-05-02 09:12:14 +02:00
Peter Krempa
78bb0df8c9 qemu: hotplug: Assume QEMU_CAPS_DEVICE in qemuDomainDetachHostPCIDevice 2016-05-02 09:12:14 +02:00
Peter Krempa
920e811f9f qemu: hotplug: Assume QEMU_CAPS_DEVICE in qemuDomainDetachControllerDevice 2016-05-02 09:12:14 +02:00
Peter Krempa
a0b38d6f9a qemu: hotplug: Assume QEMU_CAPS_DEVICE in qemuDomainDetachVirtioDiskDevice 2016-05-02 09:12:14 +02:00
Peter Krempa
62890fcf64 qemu: hotplug: Assume QEMU_CAPS_DEVICE in qemuDomainAttachHostPCIDevice 2016-05-02 09:12:14 +02:00
Peter Krempa
0a2cfaf3b1 qemu: hotplug: Assume QEMU_CAPS_DEVICE in qemuDomainAttachNetDevice 2016-05-02 09:12:14 +02:00
Peter Krempa
375a3d7585 qemu: hotplug: Assume QEMU_CAPS_DEVICE in qemuDomainAttachVirtioDiskDevice
After killing one of the conditionals it's now guaranteed to have
@drivealias populated when calling the monitor, so the code attempting
to cleanup can be simplified.
2016-05-02 09:12:14 +02:00
Peter Krempa
c01f4e9e55 qemu: monitor: Kill legacy USB monitor code
Code was obsoleted by using -device.
2016-05-02 09:12:14 +02:00
Peter Krempa
dd3e9a0a7d qemu: hotplug: Assume QEMU_CAPS_DEVICE in qemuDomainAttachHostUSBDevice 2016-05-02 09:12:14 +02:00
Peter Krempa
1cc2889f71 qemu: hotplug: Assume QEMU_CAPS_DEVICE in qemuDomainAttachUSBMassStorageDevice 2016-05-02 09:12:14 +02:00
Peter Krempa
3fbc7b781c qemu: remove default case from few typecasted enums
Commit 98c5c53d69 partially reverted the effort to use typecasted enums
for compiler notification. Turn it back.
2016-05-02 09:12:14 +02:00
Peter Krempa
22e464744d qemu: process: Don't needlesly clear the perf events in qemuDomainPerfRestart
At that point the perf events struct should not be allocated so there's
no use in clearing it.
2016-05-02 09:06:52 +02:00
Peter Krempa
edadd46c05 qemu: process: Fix failure semantics for perf events
For strange reasons if a perf event type was not supported or failed to
be enabled at VM start libvirt would ignore the failure.

On the other hand on restart if the event could not be re-enabled
libvirt would fail to reconnect to the VM and kill it.

Both don't make really sense. Fix it by failing to start the VM if the
event is not supported and change the event to disabled if it can't be
reconnected (unlikely).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1329045
2016-05-02 09:06:52 +02:00
Peter Krempa
e64e394223 util: perf: Adhere to coding style of error checks in qemuDomainSetPerfEvents 2016-05-02 09:06:52 +02:00
Peter Krempa
e08479efca qemu: perf: Don't ignore perf setup if allocation fails
Reject the VM startup if the perf event structure can't be allocated.
2016-05-02 09:06:52 +02:00
Peter Krempa
662862ec5f qemu: hotplug: Allow update of disk default snapshot location
Since the field is internal to libvirt we can allow the users to modify
it.
2016-05-02 09:03:02 +02:00
Peter Krempa
3b3debfb7f qemu: domain: Check few more fields for when changing disk source
Both disk->src->shared and disk->src->readonly can't be modified when
changing disk source for floppy and cdrom drives since both arguments
are passed as arguments of the disk rather than the image in qemu.

Historically these fields have only two possible values since they are
represented as XML thus we need to ignore if user did not provide them
and thus we are treating them as false.
2016-05-02 09:03:02 +02:00
Peter Krempa
a84d604db5 qemu: domain: Fix error message in qemuDomainDiskChangeSupported
disk->dst represents the <target> element in the XML.
2016-05-02 09:03:02 +02:00
Peter Krempa
833ae6b435 qemu: hotplug: Skip waiting for tray opening if qemu doesn't notify us
If qemu doesn't support DEVICE_TRAY_MOVED event the code that attempts
to change media would attempt to re-eject the tray even if it wouldn't
be notified when the tray opened. Add a capability bit and skip retrying
for old qemus.
2016-05-02 08:49:34 +02:00
Peter Krempa
a34faf3301 qemu: process: Refresh ejectable media tray state on VM start
Empty floppy drives start with tray in "open" state and libvirt did not
refresh it after startup. The code that inserts media into the tray then
waited until the tray was open before inserting the media and thus
floppies could not be inserted.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1326660
2016-05-02 08:49:34 +02:00
Laine Stump
9b643ae824 Revert "qemu domain allow to set ip address, peer address and route"
This reverts commit 6e244c659f, which
added support to qemu for the "peer" attribute in domain interface <ip>
elements.

It's being removed temporarily for the release of libvirt 1.3.4
because the feature doesn't work, and there are concerns that it may
need to be modified in an externally visible manner which could create
backward compatibility problems.

 Conflicts:
   tests/qemuxml2argvmock.c - a mock of virNetDevSetOnline() was added
   which may be assumed by other tests added since the original commit,
   so it isn't being reverted.
2016-04-29 12:46:30 -04:00
Martin Kletzander
55320c23dd qemu: Regenerate VNC socket paths
Similarly to what commit 7140807917 did with some internal paths,
clear vnc socket paths that were generated by us.  Having such path in
the definition can cause trouble when restoring the domain.  The path is
generated to the per-domain directory that contains the domain ID.
However, that ID will be different upon restoration, so qemu won't be
able to create that socket because the directory will not be prepared.

To be able to migrate to older libvirt, skip formatting the socket path
in migratable XML if it was autogenerated.  And mark it as autogenerated
if it already exists and we're parsing live XML.

Best viewed with '-C'.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-04-28 16:13:45 +02:00
Peter Krempa
b527e7c8e2 qemu: Error out if setting vcpu count would lead to invalid config
When the domain definition describes a machine with NUMA, setting the
maximum vCPU count via the API might lead to an invalid config.

Add a check that will forbid this until we add more advanced cpu config
capabilities.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1327499
2016-04-28 09:25:32 +02:00
Peter Krempa
63e2b766a5 qemu: conf: Set default logging approach in virQEMUDriverConfigNew
Instead of setting the default qemu stdio logging approach in
virQEMUDriverConfigLoadFile set it in virQEMUDriverConfigNew so that
it's properly set even when the config is not present.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1325075
2016-04-28 09:25:32 +02:00
Martin Kletzander
d294f6b0df Shorten domain name for automatic coredump
If the domain name is long enough, the timestamp can prolong the
filename for automatic coredump to more than the filesystem's limit.
Simply shorten it like we do in other places.  The timestamp helps with
the unification, but having the ID in the name won't hurt.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-04-27 15:08:10 +02:00
Martin Kletzander
a042275a39 Unify domain name shortening
Add virDomainObjGetShortName() and use it.  For now that's used in one
place, but we should expose it so that future patches can use it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-04-27 15:07:10 +02:00
Martin Kletzander
d3d4fb4b18 qemu: Unref cfg in qemuDomainDefPostParse
Introduced by commit 15ad2ecf11.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-04-27 15:06:09 +02:00
Michal Privoznik
927d047ee7 qemuProcessCreatePretendCmd: Rework FIPS handling
This function - in contrast with qemuBuildCommandLine - merely
constructs our internal command representation of a domain. This
is then later compared against expected output. Or, this function
is used also in virConnectDomainXMLToNative(). But due to a copy
paste error this function, just like its image - has @forceFips
argument that if enabled forces FIPS, otherwise mimics FIPS state
in the host. If FIPS is enabled or forced the generated command
line is different to state in which FIPS is disabled. Problem is,
while this could be desired in the virConnectDomainXMLToNative()
case, this is undesirable in the test suite as it will produce
unpredicted results.
Solution to this is to rename argument to @enableFips to
specifically tell whether we expect command line to be build in
either of fashions and make virConnectDomainXMLToNative()
implementation fetch FIPS state and pass it to
qemuProcessCreatePretendCmd().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-04-25 18:47:31 +02:00
Laine Stump
ff2126225d qemu: fix error log in qemuAssignPCIAddresses()
This error message was too specific, based on the incorrect assumption
that any error was cause by auto-added bridges:

  failed to create PCI bridge on bus 2: too many devices
  with fixed addresses

In practice you can't know if a bridge with an index <= the bus it's
connecting to was added automatically, or if it was a mistake in
explicit config, and the auto-add problem is going to be dealt with in
a different way in an upcoming patch. The new message is this:

  PCI Controller at index 1 (0x01) has "
  bus='0x02', but bus must be <= index

(note that index is given in both decimal and hex because it is
formatted as decimal in the XML, but bus is formatted as hex, and
displaying the hex value of index makes it easier to see the problem
when index > 9 (which will often be the case with PCIe, since most
controllers only have a single port, not 32 slots as with standard
PCI)).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1004593
2016-04-25 10:34:59 -04:00
Martin Kletzander
72c313bce9 qemu: Fix off-by-one error in block I/O throttle messages
QEMU_BLOCK_IOTUNE_MAX is the maximum inclusively, so let's modify the
message so it makes sense.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-04-25 12:16:38 +02:00
Martin Kletzander
2d04f6de77 qemu: Limit maximum block device I/O tune values
The values are currently limited to LLONG_MAX which causes some
problems.  QEMU conveniently changed their maximum to 1e15 (1 PB) which
is enough for some time and we need to adapt to that so that we don't
throw "Unknown error" messages.  Strictly limiting these values actually
fixes some corner case values (off-by-one checks in QEMU probably).

Since values out of the new specified range do not overflow anything,
change the type of error as well.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-04-22 07:29:03 +02:00
Cole Robinson
5938f2d0bd qemu: process: split out startup XML validation
And document that these specific bits are done at startup time for
back compat reasons
2016-04-21 09:29:20 -04:00
Cole Robinson
55079d6998 qemu: process: split out shmem startup warning
Now we can return early and save some indentation
2016-04-21 09:29:20 -04:00
Cole Robinson
487d211d20 storage: remove support for /usr/bin/kvm-img
This an ubuntu/debian packaging convention. At one point it may have
been an actually different binary, but at least as of ubuntu precise
(the oldest supported ubuntu distro, released april 2012) kvm-img is
just a symlink to qemu-img for back compat.

I think it's safe to drop support for it
2016-04-20 08:55:36 -04:00
Andrea Bolognani
c9458b6583 qemu: Cache GIC capabilities
Implement support for saving GIC capabilities in the cache and
read them back.
2016-04-20 12:56:47 +02:00
Andrea Bolognani
e087aa7545 qemu: Fill in GIC capabilities
Take the GIC capabilities stored in a virQEMUCaps instance and
update a virDomainCaps instance appropriately.
2016-04-20 12:55:28 +02:00
Andrea Bolognani
12209ba5bd qemu: Probe GIC capabilities
QEMU introduced the query-gic-capabilities QMP command
with commit 4468d4e0f383: use the command, if available,
to probe available GIC capabilities.

The information obtained is stored in a virQEMUCaps
instance, and will be later used to fill in a
virDomainCaps instance.
2016-04-20 12:46:48 +02:00
Andrea Bolognani
29980231db conf: Get rid of virDomainCapsDevice
The struct contains a single boolean field, 'supported':
the meaning of this field is too generic to be limited to
devices only, and in fact it's already being used for
other things like loaders and OSs.

Instead of trying to come up with a more generic name just
get rid of the struct altogether.
2016-04-20 12:41:54 +02:00
Cole Robinson
153903ec53 qemu: command: drop redundant min_guarantee check
We already reject a VM with min_guarantee early in the VM startup
in qemuProcessStartValidate
2016-04-19 11:53:28 -04:00
Cole Robinson
b0a2ba2462 qemu: Remove redundant DomainObjIsActive calls
The common idiom in the driver API implementations is roughly:

- ACL check
- BeginJob (if needed)
- AgentAvailable (if needed)
- !IsActive

A few calls had an extra !IsActive before BeginJob, which doesn't
seem to serve much use. Drop them
2016-04-19 11:53:28 -04:00
Martin Kletzander
32f3f0835e security: Rename DomainSetDirLabel to DomainSetPathLabel
It already labels abritrary paths, so it's just the naming that was
wrong.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-04-18 20:34:30 +02:00
Dmitry Andreev
b028e9d7c2 qemu: migration: new migration param for persistent destination XML
Migration API allows to specify a destination domain configuration.
Offline domain has only inactive XML and it is replaced by configuration
specified using VIR_MIGRATE_PARAM_DEST_XML param. In case of live
migration VIR_MIGRATE_PARAM_DEST_XML param is applied for active XML.

This commit introduces the new VIR_MIGRATE_PARAM_PERSIST_XML param
that can be used within live migration to replace persistent/inactive
configuration.

Required for: https://bugzilla.redhat.com/show_bug.cgi?id=835300
2016-04-18 14:45:58 +02:00
Dmitry Andreev
dc311c64ea qemuMigrationCookieAddPersistent: move it out and change argument type
This changes allow to use qemuMigrationCookieAddPersistent with
an XML definition that isn't assigned to any domain.
2016-04-18 14:02:39 +02:00
John Ferlan
727a3c5860 Resolve a couple of memory leaks
Commit id '4b75237f' seems to have triggered Coverity into finding
at least one memory leak in xen_xl.c for error path for cleanup where
the listenAddr would be leaked. Reviewing other callers, it seems that
qemu_parse_command.c would have the same issue, so just it too.
2016-04-16 08:04:14 -04:00
John Ferlan
6c09c17e0d qemu: Fix qemuBuildCommandLine prototype
Commit id '0da965c5e' removed the 11th parameter, but neglected to
remove the ATTRIBUTE_NONNULL for it and adjust the 17th and 18th.
2016-04-16 08:04:14 -04:00
Martin Kletzander
744d74fafd qemu: Label master key file
When creating the master key, we used mode 0600 (which we should) but
because we were creating it as root, the file is not readable by any
qemu running as non-root.  Fortunately, it's just a matter of labelling
the file.  We are generating the file path few times already, so let's
label it in the same function that has access to the path already.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-04-15 12:15:28 -04:00
Richard W.M. Jones
beaa447a29 Add functions for handling exponential backoff loops.
In a few places in libvirt we busy-wait for events, for example qemu
creating a monitor socket.  This is problematic because:

 - We need to choose a sufficiently small polling period so that
   libvirt doesn't add unnecessary delays.

 - We need to choose a sufficiently large polling period so that
   the effect of busy-waiting doesn't affect the system.

The solution to this conflict is to use an exponential backoff.

This patch adds two functions to hide the details, and modifies a few
places where we currently busy-wait.

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
2016-04-15 16:54:28 +01:00
Peter Krempa
6306ee6249 qemu: hotplug: Properly recalculate/reload balloon size after hot(un)plug
Rather than trying some magic calculations on our side query the monitor
for the current size of the memory balloon both on hotplug and
hotunplug.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1220702
2016-04-15 14:27:09 +02:00
Peter Krempa
1996da216a qemu: process: Simplify condition in qemuProcessRefreshBalloonState
No need to store failure and re-check right away.
2016-04-15 14:27:09 +02:00
Peter Krempa
c0e962b6f3 qemu: driver: Reuse qemuDomainGetMonitor in qemuDomainMemoryStats 2016-04-15 14:27:09 +02:00
Peter Krempa
d6cb0d256a domain: Add helper to determine presence of memory baloon 2016-04-15 14:27:08 +02:00
Peter Krempa
33b9598c41 qemu: command: Refactor memballoon command line formatting
Now that there is just one format of the memory balloon command line
used the code can be merged into a single function.

Additionally with some tweaks to the control flow the code is easier to
read.
2016-04-15 14:27:08 +02:00
Peter Krempa
388b356e5d qemu: command: Drop obsolete comment
The change that made qemu not add the memballoon by default happened
prior to 0.12.0. Additionaly the comment was misleading due to the code
that was added below. Since we always need to add a balloon on the
commandline drop the comment.
2016-04-15 14:27:08 +02:00
Peter Krempa
2242a00822 qemu: caps: Deprecate QEMU_CAPS_BALLOON
The flag is now unused and all qemus supported by libvirt already
support it.
2016-04-15 14:27:08 +02:00
Peter Krempa
c1300176f7 qemu: command: Assume QEMU_CAPS_DEVICE when building memballoon args 2016-04-15 14:27:08 +02:00
Cole Robinson
dae0e22714 qemu: migration: Drop dead VNC cookie handling
The only caller of this code is:

    for (i = 0; i < dom->def->ngraphics; i++) {
       if (dom->def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
           if (!(mig->graphics =
                 qemuMigrationCookieGraphicsAlloc(driver, dom->def->graphics[i])))
               return -1;
           mig->flags |= QEMU_MIGRATION_COOKIE_GRAPHICS;
           break;
       }
    }

So this is never triggered for VNC, and in fact VNC has no support for
seamless migration anyways so that seems correct. Drop the dead VNC
handling.
2016-04-15 07:54:49 -04:00
Laine Stump
8b62c65d24 qemu: support new pci controller model "pcie-expander-bus"
This is backed by the qemu device pxb-pcie, which will be available in
qemu 2.6.0.

As with pci-expander-bus (which uses qemu's pxb device), the busNr
attribute and <node> subelement of <target> are used to set the bus_nr
and numa_node options.

During post-parse we validate that the domain's machinetype is
q35-based (since the device shows up for 440fx-based machinetypes, but
is unusable), as well as checking that <node> specifies a node that is
actually configured on the guest.
2016-04-14 14:00:34 -04:00
Laine Stump
bc07251f59 conf: new pci controller model pcie-expander-bus
This controller provides a single PCIe port on a new root. It is
similar to pci-expander-bus, intended to provide a bus that can be
associated with a guest-identifiable NUMA node, but is for
machinetypes with PCIe rather than PCI (e.g. q35-based machinetypes).

Aside from PCIe vs. PCI, the other main difference is that a
pci-expander-bus has a companion pci-bridge that is automatically
attached along with it, but pcie-expander-bus has only a single port,
and that port will only connect to a pcie-root-port, or to a
pcie-switch-upstream-port. In order for the bus to be of any use in
the guest, it must have either a pcie-root-port or a
pcie-switch-upstream-port attached (and one or more
pcie-switch-downstream-ports attached to the
pcie-switch-upstream-port).
2016-04-14 14:00:34 -04:00
Laine Stump
0ec0bc85d0 qemu: add capabilities bit for device "pxb-pcie"
The pxb device is a PCIe expander bus that can be added to any
    Q35-based machinetype. A single PCIe port (*not* hotpluggable) is
    provided; if more than one device is desired, or if hotplug
    support is needed, either a pcie-root-port, or some combination of
    pcie-switch-upstream-port and pcie-swith-downstream-ports must be
    added to it. It can have a NUMA node number associated with it, as
    well as a bus number.
2016-04-14 14:00:34 -04:00
Laine Stump
400b297692 qemu: support new pci controller model "pci-expander-bus"
This is backed by the qemu device "pxb".

The pxb device always includes a pci-bridge that is at the bus number
of the pxb + 1.

busNr and <node> from the <target> subelement are used to set the
bus_nr and numa_node options for pxb.

During post-parse we validate that the domain's machinetype is
440fx-based (since the pxb device only works on 440fx-based machines),
and <node> also gets a sanity check to assure that the NUMA node
specified for the pxb (if any - it's optional) actually exists on the
guest.
2016-04-14 14:00:34 -04:00
Laine Stump
52f3d0a4d2 conf: new pci controller model pci-expander-bus
This is a standard PCI root bus (not a bridge) that can be added to a
440fx-based domain. Although it uses a PCI slot, this is *not* how it
is connected into the PCI bus hierarchy, but is only used for
control. Each pci-expander-bus provides 32 slots (0-31) that can
accept hotplug of standard PCI devices.

The usefulness of pci-expander-bus relative to a pci-bridge is that
the NUMA node of the bus can be specified with the <node> subelement
of <target>. This gives guest-side visibility to the NUMA node of
attached devices (presuming that management apps only assign a device
to a bus that has a NUMA node number matching the node number of the
device on the host).

Each pci-expander-bus also has a "busNr" attribute. The expander-bus
itself will take the busNr specified, and all buses that are connected
to this bus (including the pci-bridge that is automatically added to
any expander bus of model "pxb" (see the next commit)) will use
busNr+1, busNr+2, etc, and the pci-root (or the expander-bus with next
lower busNr) will use bus numbers lower than busNr.
2016-04-14 14:00:34 -04:00
Laine Stump
5d4e2b1721 qemu: add capabilities bit for device "pxb"
The pxb device is a PCI expander bus that can be added to any
440fx-based machinetype. The PCI bus that is created has 32 standard
PCI slots (hotpluggable). It can have a NUMA node number associated
with it, as well as a bus number.
2016-04-14 14:00:34 -04:00
Laine Stump
1da284736e qemu: set PCI controller default modelName in a separate function
Since every PCI controller model has to have a default model name set,
put it in a separate function to clean up qemuDomainAssignPCIAddresses
a bit.
2016-04-14 14:00:34 -04:00
Laine Stump
a0616ee8a8 conf: utility function to convert PCI controller model into connect type
There are two places in qemu_domain_address.c where we have a switch
statement to convert PCI controller models
(VIR_DOMAIN_CONTROLLER_MODEL_PCI*) into the connection type flag that
is matched when looking for an upstream connection for that model of
controller (VIR_PCI_CONNECT_TYPE_*). This patch makes a utility
function in conf/domain_addr.c to do that, so that when a new PCI
controller is added, we only need to add the new model-->connect-type
in a single place.
2016-04-14 14:00:34 -04:00
Laine Stump
d1cc4605d7 conf/qemu: change the way VIR_PCI_CONNECT_TYPE_* flags work
The flags used to determine which devices could be plugged into which
controllers were quite confusing, as they tried to create classes of
connections, then put particular devices into possibly multiple
classes, while sometimes setting multiple flags for the controllers
themselves. The attempt to have a single flag indicate, e.g. that a
root-port or a switch-downstream-port could connect was not only
confusing, it was leading to a situation where it would be impossible
to specify exactly the right combinations for a new controller.

The solution is for the VIR_PCI_CONNECT_TYPE_* flags to have a 1:1
correspondence with each type of PCI controller, plus a flag for a PCI
endpoint device and another for a PCIe endpoint device (the only
exception to this is that pci-bridge and pcie-expander-bus controllers
have their upstream connection classified as
VIR_PCI_CONNECT_TYPE_PCI_DEVICE since they can be plugged into
*exactly* the same ports as any endpoint device).  Each device then
has a single flag for connect type (plus the HOTPLUG flag if that
device can e hotplugged), and each controller sets the CONNECT bits
for all controllers that can be plugged into it, as well as for either
type of endpoint device that can be plugged in (and the HOTPLUG flag
if it can accept hotplugged devices).

With this change, it is *slightly* easier to understand the matching
of connections (as long as you remember that the flag for a
device/upstream-facing connection of a controller is the same as that
device's type, while the flags for a controller's downstream
connections is the OR of all device types that can be plugged into
that controller). More importantly, it will be possible to correctly
specify what can be plugged into a pcie-switch-expander-bus, when
support for it is added.
2016-04-14 14:00:34 -04:00
Cole Robinson
a91177c8f7 qemu: command: don't overwrite watchdog dump action
The watchdog cli refactoring in 4666b762 dropped the temporary variable
we use to convert to action=dump to action=pause for the qemu cli, and
stored the converted value in the domain structure. Our other watchdog
handling code then treated it as though the user requested action=pause,
which broke action=dump handling.

Revive the temporary variable to fix things.
2016-04-14 12:28:04 -04:00
Nikolay Shirokovskiy
061e24285f qemu: migration: support setting compession parameters
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-04-14 14:57:41 +02:00
ShaoHe Feng
8979c5ddb9 qemu: monitor: add migration parameters accessors
Signed-off-by: ShaoHe Feng <shaohe.feng@intel.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-04-14 14:57:40 +02:00
Nikolay Shirokovskiy
231b25db67 migration: qemu: add option to select compression methods
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-04-14 14:57:40 +02:00
Martin Kletzander
fb6ec0ed3d Fix various shadowed declarations
I tried compiling libvirt with older gcc and probably because I used
different configure options I got some shadowed declarations.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-04-14 08:55:08 +02:00
Pavel Hrdina
6e76738e54 build: fix build on RHEL-6
GCC in RHEL-6 complains about listen:

../../src/conf/domain_conf.c:23718: error: declaration of 'listen' shadows a global declaration [-Wshadow]
/usr/include/sys/socket.h:204: error: shadowed declaration is here [-Wshadow]

This renames all the listen to gListen.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-04-13 17:28:50 +02:00
Ján Tomko
d5a49e5d4c qemuExecuteEthernetScript: move to util
This is just a wrapper for virCommand that takes two strings
and runs them.

Move it to virnetdev.c for easier mocking.
2016-04-13 15:01:17 +02:00
Peter Krempa
0ad64e20d8 qemu: process: Wire up ACPI OST events to notify users of failed memory unplug
Since qemu is now able to notify us that the guest rejected the memory
unplug operation we can relay this to the user and make the API fail
right away.

Additionally document the possible values from the ACPI docs for future
reference.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1320447
2016-04-13 13:26:29 +02:00
Peter Krempa
650e8d2c59 qemu: monitor: Add support for ACPI_DEVICE_OST event handling
The event is emitted on ACPI OSPM Status Indication events.

ACPI standard documentation describes the method as:

This object is an optional control method that is invoked by OSPM to
indicate processing status to the platform. During device ejection,
device hot add, or other event processing, OSPM may need to perform
specific handshaking with the platform. OSPM may also need to indicate
to the platform its inability to complete a requested operation; for
example, when a user presses an ejection button for a device that is
currently in use or is otherwise currently incapable of being ejected.
In this case, the processing of the ACPI Eject Request notification by
OSPM fails. OSPM may indicate this failure to the platform through the
invocation of the _OST control method. As a result of the status
notification indicating ejection failure, the platform may take certain
action including reissuing the notification or perhaps turning on an
appropriate indicator light to signal the failure to the user.
2016-04-13 13:26:29 +02:00
Peter Krempa
1ac3864025 qemu: hotplug: Add support for signalling device unplug failure
Similarly to the DEVICE_DELETED event we will be able to tell when
unplug of certain device types will be rejected by the guest OS. Wire up
the device deletion signalling code to allow handling this.
2016-04-13 13:26:29 +02:00
Peter Krempa
0f621198a4 qemu: Use domain condition for device removal signaling
No need to keep two separate conditions. A slight juggling of return
values is needed to accomodate virDomainObjWaitUntil.
2016-04-13 13:26:29 +02:00
Peter Krempa
986a016c5d qemu: hotplug: Refactor semantics of qemuDomainWaitForDeviceRemoval
Neither of the callers cares whether the DEVICE_DELETED event isn't
supported or the event was received. Simplify the code and callers by
unifying the two values and changing the return value constants so that
a temporary variable can be omitted.
2016-04-13 13:26:29 +02:00
Peter Krempa
65b390ad1b qemu: hotplug: Properly handle errors in qemuDomainWaitForDeviceRemoval
Callers ignore if this function returns -1 and continue as though the
DEVICE_DELETED event was not received. Since we can't be sure that the
event was not received we should behave as if the event was not
supported and remove the device definition right away. The error
fortunately won't really happen here.
2016-04-13 13:26:29 +02:00
Ján Tomko
786bc2511a qemu: assign addresses before aliases
The address assigning code might add new pci bridges.
We need them to have an alias when building the command line.

In real word usage, this is not a problem because all the code
paths already call qemuDomainAssignAddresses. However moving
this call lets us remove one extra call from qemuxml2argvtest.
2016-04-13 13:07:20 +02:00
Ján Tomko
0da965c5e0 drop qemuBuildCommandLineCallbacks
Essentially revert commit 3a6204c which added these to allow the test
suite to pass without depending on the host system state.

Since commit 4b527c1 we already mock virSCSIDeviceGetSgName, so these
callbacks are useless.
2016-04-13 13:00:53 +02:00
Pavel Hrdina
f53bb3eda9 use virDomainGraphicsGetListen instead of the other getters
There is no point the use two different getters on the same listen
structure few lines apart.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-04-13 10:43:49 +02:00
Pavel Hrdina
4b75237fe6 domain_conf: introduce virDomainGraphicsListenAppendAddress
This effectively removes virDomainGraphicsListenSetAddress which was
used only to change the address of listen structure and possible change
the listen type.  The new function will auto-expand the listens array
and append a new listen.

The old function was used on pre-allocated array of listens and in most
cases it only "add" a new listen.  The two remaining uses can access the
listen structure directly.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-04-13 10:43:49 +02:00
Martin Kletzander
16b41728b5 qemu: Free priv->machineName
Commit c3bd0019c0 forgot to cleanup after itself.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-04-11 11:46:09 +02:00
Peter Krempa
a46aad791c qemu: agent: Fix incorrect and weird debug/warning log entries
Replace the nonsensical debug statement by adding the expected event
code into the existing debug statement.

Since the monitor code always notifies the agent on guest
reboot/shutdown even if that was not initiated by the agent the warning
emitted later is bogus and pollutes the logs in such cases. Delete it
and keep just the original debug message where this info can be
inferred.
2016-04-11 09:48:13 +02:00
Roman Bogorodskiy
acb63aaf41 qemu: fix build without gnutls installed
Move including of gnutls/gnutls.h in qemu/qemu_domain.c under the
"ifdef WITH_GNUTLS" check because otherwise it fails like this:

  CC       qemu/libvirt_driver_qemu_impl_la-qemu_domain.lo
qemu/qemu_domain.c:50:10: fatal error: 'gnutls/gnutls.h' file not found

in case if gnutls is not installed on the system.
2016-04-09 22:04:40 +03:00
Ján Tomko
f06ca25d23 qemu: support virt-2.6 machine type on arm
Some places already check for "virt-" prefix as well as plain "virt".
virQEMUCapsHasPCIMultiBus did not, resulting in multiple PCI devices
having assigned the same unnumbered "pci" alias.

Add a test for the "virt-2.6" machine type which also omits the
<model type='virtio'/> in <interface>, to check if
qemuDomainDefaultNetModel works too.

https://bugzilla.redhat.com/show_bug.cgi?id=1325085
2016-04-08 14:15:51 +02:00
Vasiliy Tolstov
6e244c659f qemu domain allow to set ip address, peer address and route
Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
2016-04-07 18:34:48 +01:00
Andrea Bolognani
2d23d145a6 qemu: Explicitly check for gnutls_rnd()
Our use of gnutls_rnd(), introduced with commit ad7520e8, is
conditional to the availability of the <gnutls/crypto.h> header
file.

Such check, however, turns out not to be strict enough, as there
are some versions of GnuTLS (eg. 2.8.5 from CentOS 6) that provide
the header file, but not the function itself, which was introduced
only in GnuTLS 2.12.0.

Introduce an explicit check for the function.
2016-04-07 17:55:53 +02:00
Peter Krempa
03e8d5fb54 qemu: perf: Fix crash/memory corruption on failed VM start
The new perf code didn't bother to clear a pointer in 'priv' causing a
double free or other memory corruption goodness if a VM failed to start.

Clear the pointer after freeing the memory.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1324757
2016-04-07 12:50:15 +02:00
Peter Krempa
be6e92f541 qemu: alias: Fix calculation of memory device aliases
For device hotplug, the new alias ID needs to be checked in the list
rather than using the count of devices. Unplugging a device that is not
last in the array will make further hotplug impossible due to alias
collision.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1324551
2016-04-07 09:54:40 +02:00
Peter Krempa
bd19b4b25b qemu: alias: Fix calculation of RNG device aliases
For device hotplug, the new alias ID needs to be checked in the list
rather than using the count of devices. Unplugging a device that is not
last in the array will make further hotplug impossible due to alias
collision.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1324551
2016-04-07 09:51:29 +02:00
John Ferlan
2844de6f40 secret: Introduce virSecretGetSecretString
Commit id 'fb2bd208' essentially copied the qemuGetSecretString
creating an libxlGetSecretString.  Rather than have multiple copies
of the same code, create src/secret/secret_util.{c,h} files and
place the common function in there.

Modify the the build in order to build the module as a library
which is then pulled in by both the qemu and libxl drivers for
usage from both qemu_command.c and libxl_conf.c
2016-04-06 20:31:21 -04:00
John Ferlan
d8a8cae342 qemu: Introduce qemuBuildMasterKeyCommandLine
If the -object secret capability exists, then get the path to the
masterKey file and provide that to qemu. Checking for the existence
of the file before passing to qemu could be done, but causes issues
in mock test environment.

Since the qemuDomainObjPrivate is not available when building the
command line, the qemuBuildHasMasterKey API will have to suffice
as the primary arbiter for whether the capability exists in order
to find/return the path to the master key for usage.

Created the qemuDomainGetMasterKeyAlias API which will be used by
later patches to define the 'keyid' (eg, masterKey) to be used by
other secrets to provide the id to qemu for the master key.
2016-04-06 20:27:09 -04:00
John Ferlan
ad7520e83f qemu: Create domain master key
Add a masterKey and masterKeyLen to _qemuDomainObjPrivate to store a
random domain master key and its length in order to support the ability
to encrypt/decrypt sensitive data shared between libvirt and qemu. The
key will be base64 encoded and written to a file to be used by the
command line building code to share with qemu.

New API's from this patch:

  qemuDomainGetMasterKeyFilePath:
    Return a path to where the key is located

  qemuDomainWriteMasterKeyFile: (private)
    Open (create/trunc) the masterKey path and write the masterKey

  qemuDomainMasterKeyReadFile:
    Using the master key path, open/read the file, and store the
    masterKey and masterKeyLen. Expected use only from qemuProcessReconnect

  qemuDomainGenerateRandomKey: (private)
    Generate a random key using available algorithms

    The key is generated either from the gnutls_rnd function if it
    exists or a less cryptographically strong mechanism using
    virGenerateRandomBytes

   qemuDomainMasterKeyRemove:
    Remove traces of the master key, remove the *KeyFilePath

  qemuDomainMasterKeyCreate:
    Generate the domain master key and save the key in the location
    returned by qemuDomainGetMasterKeyFilePath.

    This API will first ensure the QEMU_CAPS_OBJECT_SECRET is set
    in the capabilities. If not, then there's no need to generate
    the secret or file.

The creation of the key will be attempted from qemuProcessPrepareHost
once the libDir directory structure exists.

The removal of the key will handled from qemuProcessStop just prior
to deleting the libDir tree.

Since the key will not be written out to the domain object XML file,
the qemuProcessReconnect will read the saved file and restore the
masterKey and masterKeyLen.
2016-04-06 20:27:09 -04:00
John Ferlan
d125685ad3 qemu: Add capability bit for qemu secret object
Add a capability bit for the qemu secret object.

Adjust the 2.6.0-1 caps/replies to add the secret object. For the
.replies it's take from the '{"execute":"qom-list-types"}' output.
2016-04-06 20:27:09 -04:00
John Ferlan
2fbf29a529 qemu: Tear down the cgroup before reattach device to host
When a hostdev is attached to the guest (and removed from the host),
the order of operations is call qemuHostdevPreparePCIDevices to remove
the device from the host, call qemuSetupHostdevCgroup to setup the cgroups,
and virSecurityManagerSetHostdevLabel to set the labels.

When the device is removed from the guest, the code didn't use the
reverse order leading to possible issues (especially if the path to
the device no longer exists). This patch will move the call to
qemuTeardownHostdevCgroup to prior to reattaching the device to
the host.
2016-04-06 20:22:29 -04:00
John Ferlan
409de00e3d qemu: Restore label before reattach device to host
When a hostdev is attached to the guest (and removed from the host),
the order of operations is call qemuHostdevPreparePCIDevices to remove
the device from the host, call qemuSetupHostdevCgroup to setup the cgroups,
and virSecurityManagerSetHostdevLabel to set the labels.

When the device is removed from the guest, the code didn't use the
reverse order leading to possible issues (especially if the path to
the device no longer exists). This patch will move the call to
virSecurityManagerRestoreHostdevLabel to prior to reattaching the
device to the host.
2016-04-06 20:22:29 -04:00
Peter Krempa
e0a34e76ef conf: store bootindex as unsigned int
The value is never negative thus there's no need to store it in a signed
type.
2016-04-06 09:27:23 +02:00
John Ferlan
2cc91ddd2d qemu: Fix mis-merge of qemuBuildRedirdevCommandLine
Commit id '59e7ef3c' misapplied a merge of commit id '019244751'
to place the "-chardev" command after formatting the character
backend value.
2016-04-04 15:30:18 -04:00
John Ferlan
28e960b691 qemu: Fix mis-merge of qemuBuildConsoleCommandLine
Commit id 'e6944a52' misapplied a merge of commit id '019244751'
to place the "-chardev" command after formatting the character
backend value.
2016-04-04 15:30:18 -04:00
John Ferlan
48d5b3d81d qemu: Fix mis-merge of qemuBuildChannelsCommandLine
Commit id '3cdcc910' misapplied a merge of commit id '019244751'
to place the "-chardev" command after formatting the character
backend value.
2016-04-04 15:30:14 -04:00
John Ferlan
6a97e35f82 qemu: Fix mis-merge of qemuBuildParallelsCommandLine
Commit id '0e1e7ade' misapplied a merge of commit id '019244751'
to place the "-chardev" command after formatting the character
backend value.
2016-04-04 15:23:07 -04:00
John Ferlan
3281b47e47 qemu: Fix mis-merge of qemuBuildSerialCommandLine
Commit id '5ab8640' misapplied a merge of commit id '019244751'
to place the "-chardev" command after formatting the character
backend value.
2016-04-04 15:21:57 -04:00
John Ferlan
344bcd89eb qemu: Fix mis-merge of qemuBuildSmartcardCommandLine
Commit id '858bafeb' misapplied a merge of commit id '019244751'
to place the "-chardev" command after formatting the character
backend value.
2016-04-04 15:19:57 -04:00
Laine Stump
8f74f5277d qemu: fix alias name for <interface type='hostdev'>
Starting with commit f8e712fe, if you start a domain that has an
<interface type='hostdev' (or that has <interface type='network'>
where the network is a pool of devices for hostdev assignment), when
you later try to add *another* interface (of any kind) with hotplug,
the function qemuAssignDeviceNetAlias() fails as soon as it sees a
"hostdevN" alias in the list of interfaces), causing the attach to
fail.

This is because (starting with f8e712fe) the device alias names are
assigned during the new function qemuProcessPrepareDomain(), which is
called *before* networkAllocateActualDevice() (which is called from
qemuProcessPrepareHost(), which is called from
qemuProcessLaunch()). Prior to that commit,
networkAllocateActualDevice() was called first.

The problem with this is that the alias for interfaces that are really
a hostdev (<interface type='hostdev'>) is of the form "hostdevN" (just
like other hostdevs), while other interfaces are "netN". But if you
don't know that the interface is going to be a hostdev at the time you
assign the alias name, you can't name it differently. (As far as I've
seen so far, the change in name by itself wouldn't have been a problem
(other than just an outwardly noticeable change in behavior) except
for the abovementioned failure to attach/detach new interfaces.

Rather than take the chance that there may be other not-yet-revealed
problems associated with changing the alias name, this patch changes
the way that aliases are assigned to restore the old behavior.

Old: In the past, assigning an alias to an interface was skipped if it
was seen that the interface was type='hostdev' - we knew that the
hostdev part of the interface was also in the list of hostdevs (that's
part of what happens in networkAllocateActualDevice()) and it would be
assigned when all the other hostdev aliases were assigned.

New: When assigning an alias to an interface, we haven't yet called
networkAllocateActualDevice() to construct the hostdev part of the
interface, so we can't just wait for the loop that creates aliases for
all the hostdevs (there's nothing on that list for this device
yet!). Instead we handle it immediately in the loop creating interface
aliases, by calling the new function networkGetActualType() to
determine if it is going to be hostdev, and if so calling
qemuAssignDeviceHostdevAlias() instead.

Some adjustments have to be made to both
qemuAssignDeviceHostdevAlias() and to qemuAssignDeviceNetAlias() to
accommodate this. In both of them, an error return from
qemuDomainDeviceAliasIndex() is no longer considered an error; instead
it's just ignored (because it almost certainly means that the alias
string for the device was "net" when we expected "hostdev" or vice
versa). in qemuAssignDeviceHostdevAlias() we have to look at all
interface aliases for hostdevN in addition to looking at all hostdev
aliases (this wasn't necessary in the past, because both the interface
entry and the hostdev entry for the device already pointed at the
device info; no longer the case since the hostdev entry hasn't yet
been setup).

Fortunately the buggy behavior hasn't yet been in any official release
of libvirt.
2016-04-04 07:33:13 -04:00
Laine Stump
f09c7139b0 qemu: change args to qemuAssignDeviceHostdevAlias()
In certain cases, we need to assign a hostdevN-style alias in a case
when we don't have a virDomainHostdevDefPtr (instead we have a
virDomainNetDefPtr). Since qemuAssignDeviceHostdevAlias() doesn't use
anything in the virDomainHostdevDef except the alias string itself
anyway, this patch just changes the arguments to pass a pointer to the
alias pointer instead.
2016-04-04 07:29:37 -04:00
Martin Kletzander
d558fb34fd qemu: Clear generated private paths
The paths have the domain ID in them.  Without cleaning them, they would
contain the same ID even after multiple restarts.  That could cause
various problems, e.g. with access.

Add function qemuDomainClearPrivatePaths() for this as a counterpart of
qemuDomainSetPrivatePaths().

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-04-04 08:17:10 +02:00
Martin Kletzander
1893b6df11 qemu: Simplify calls to qemuDomainSetPrivatePaths
Since commit 9dca74ee6f, the function can take driver and a vm, no
need to overcomplicate.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-04-04 08:17:10 +02:00
Rudy Zhang
abf50874d6 migration: convert speed from MiB/sec to bytes/sec in drive-mirror jobs
Commit 08cc14f moved the conversion of MiB/s to B/s out of the
qemuMonitor APIs, but forgot to adjust the qemuMigrationDriveMirror
caller.

This patch will convert the migrate_speed value from MiB/s to its
mirror_speed equivalent in bytes/s.

Signed-off-by: Rudy Zhang <rudyflyzhang@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2016-04-01 10:58:47 +02:00
Peter Krempa
1d8351a94f qemu: perf: Tweak flags before using them
@flags have a valid modification impact only after calling
virDomainObjUpdateModificationImpact. virDomainObjGetOneDef calls it but
doesn't update them in the caller.
2016-04-01 09:52:24 +02:00
Michal Privoznik
382ea24b1a qemuProcessVerifyGuestCPU: Avoid coverity false positive
We use _LAST items in enums to mark the last position in given
enum. Now, if and enum is passed to switch(), compiler checks
that all the values from enum occur in 'case' enumeration.
Including _LAST. But coverity spots it's a dead code. And it
really is. So to resolve this, we tend to put a comment just
above 'case ..._LAST' notifying coverity that we know this is a
dead code but we want to have it that way.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-31 17:25:21 +02:00
Michal Privoznik
4349e24d54 virDomain{Get,Set}PerfEvents: Grab job
Even though we have the machine locked throughout whole APIs we
are querying/modifying domain internal state. We should grab a
job whilst doing that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-31 10:48:41 +02:00
Michal Privoznik
ed504ba392 virDomain{Get,Set}PerfEvents: support --config --live --current
Now that we have @flags we can support changing perf events just
in active or inactive configuration regardless of the other.
Previously, calling virDomainSetPerfEvents set events in both
active and inactive configuration at once. Even though we allow
users to set perf events that are to be enabled once domain is
started up. The virDomainGetPerfEvents API was flawed too. It
returned just runtime info.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-31 10:42:46 +02:00
Michal Privoznik
3b6c818532 virDomain{Get,Set}PerfEvents: Add @flags argument
I've noticed that these APIs are missing @flags argument. Even
though we don't have a use for them, it's our policy that every
new API must have @flags.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-31 07:24:36 +02:00
Peter Krempa
13a4ec678f qemu: command: Split up formatting of -numa and memory devices
They recently were extracted to a separate function. They don't belong
together though. Since -numa formatting is pretty compact, move it to
the main function and rename qemuBuildNumaCommandLine to
qemuBuildMemoryDeviceCommandLine.
2016-03-30 13:56:43 +02:00
Peter Krempa
25c39f76b8 qemu: command: Pass numad nodeset when formatting memory devices at boot
When starting up a VM libvirtd asks numad to place the VM in case of
automatic nodeset. The nodeset would not be passed to the memory device
formatter and the user would get an error.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1269715
2016-03-30 13:56:43 +02:00
Pavel Hrdina
95bbe4bf52 qemu_process: add check for hyperv features
Commit 7068b56c introduced several hyperv features.  Not all hyperv
features are supported by old enough kernels and we shouldn't allow to
start a guest if kernel doesn't support any of the hyperv feature.

There is one exception, for backward compatibility we cannot error out
if one of the RELAXED, VAPIC or SPINLOCKS isn't supported, for the same
reason we ignore invtsc, to not break restoring saved domains with older
libvirt.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-30 10:35:15 +02:00
Pavel Hrdina
e7cc2e3bef qemu_process: skip only cpu features
This check is there to allow restore saved domain with older libvirt
where we included invtsc by default for host-passthrough model.  Don't
skip the whole function, but only the part that checks for invtsc.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-30 10:35:15 +02:00
Jiri Denemark
801a5f65fa qemu: Fix /proc/**/stat parsing
Since commit v1.3.2-119-g1e34a8f which enabled debug-threads in QEMU
qemuGetProcessInfo would fail to parse stats for any thread with a space
in its name.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-29 16:41:20 +02:00
Peter Krempa
0c8e3b2234 qemu: domain: Move and export qemuDomainDiskChainElement(Prepare|Revoke)
Move the function to qemu_domain.c and export them for further use.
2016-03-29 15:25:16 +02:00
Peter Krempa
358c18c391 qemu: Refactor qemuDomainPrepareDiskChainElement
Now that there are only two elements in the enum, let's change it to a
bool and rename the function similarly to the one added in previous
commit.
2016-03-29 15:25:16 +02:00
Peter Krempa
5126174357 qemu: Split image access revoking from qemuDomainPrepareDiskChainElement
Introduce qemuDomainDiskChainElementRevoke that revokes the access
rather than having a flag to do so.
2016-03-29 15:25:16 +02:00