Commit Graph

167 Commits

Author SHA1 Message Date
Prasanna Kumar Kalever
e66603539b qemu: command: Add debug option for gluster volumes
Propagate the selected or default level to qemu if it's supported.

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

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2016-11-09 16:52:40 +01:00
Martin Kletzander
06524fd52c qemu: Support newer ivshmem device variants
QEMU added support for ivshmem-plain and ivshmem-doorbell.  Those are
reworked varians of legacy ivshmem that are compatible from the guest
POV, but not from host's POV and have sane specification and handling.

Details about the newer device type can be found in qemu's commit
5400c02b90bb:

  http://git.qemu.org/?p=qemu.git;a=commit;h=5400c02b90bb

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-11-02 17:36:17 +01:00
John Ferlan
daf5c651f0 qemu: Add a secret object to/for a char source dev
Add the secret object so the 'passwordid=' can be added if the command line
if there's a secret defined in/on the host for TCP chardev TLS objects.

Preparation for the secret involves adding the secinfo to the char source
device prior to command line processing. There are multiple possibilities
for TCP chardev source backend usage.

Add test for at least a serial chardev as an example.
2016-10-26 07:18:25 -04:00
Martin Kletzander
c7e0a6a667 qemu: Make qemuBuildShmemDevStr static
It isn't used anywhere else.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-09-20 15:42:43 +02:00
Daniel P. Berrange
92513bc23a qemu: avoid parameter named 'listen'
previous commit:

  commit 2c3223785c
  Author: John Ferlan <jferlan@redhat.com>
  Date:   Mon Jun 13 12:30:34 2016 -0400

    qemu: Add the ability to hotplug the TLS X.509 environment

added a parameter "bool listen" in some methods. This
unfortunately clashes with the listen() method, causing
compile failures on certain platforms (RHEL-6 for example)

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-09-12 15:49:28 +01:00
John Ferlan
2c3223785c qemu: Add the ability to hotplug the TLS X.509 environment
If the incoming XML defined a path to a TLS X.509 certificate environment,
add the necessary 'tls-creds-x509' object to the VIR_DOMAIN_CHR_TYPE_TCP
character device.

Likewise, if the environment exists the hot unplug needs adjustment as
well.  Note that all the return ret were changed to goto cleanup since
the cfg needs to be unref'd

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-09-09 08:09:47 -04:00
Peter Krempa
8807f28b85 qemu: command: Add helper to convert vcpu definition to JSON props
For use on the monitor we need to format certain parts of the vcpu
private definition into a JSON object. Add a helper.
2016-08-24 15:44:47 -04:00
John Ferlan
13effcafd2 qemu: Use qemuAliasFromDisk instead of qemuDeviceDriveHostAlias
Since we already have a function that will generate the drivestr from
the alias, let's use it and remove the qemuDeviceDriveHostAlias.

Move the QEMU_DRIVE_HOST_PREFIX definition into qemu_alias.h

Also alter qemuAliasFromDisk to use the QEMU_DRIVE_HOST_PREFIX instead
of "drive-%s".
2016-08-02 10:11:11 -04:00
John Ferlan
c6910bd4c7 qemu: Make qemuBuildSecretInfoProps global
Need to create the object for a hotplug disk
2016-06-24 13:04:38 -04:00
John Ferlan
7d49f2c199 qemu: Make qemuBuildShmemBackendStr private
It's not used externally anywhere else

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-06-16 11:57:45 -04:00
Martin Kletzander
f670008b58 qemu: Move channel path generation out of command creation
Put it into separate function called qemuDomainPrepareChannel() and call
it from the new qemuProcessPrepareDomain().

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-06-09 13:23:15 +02:00
John Ferlan
1b5f1884a2 qemu: Move and rename qemuBuildObjectCommandlineFromJSON
Move the module from qemu_command.c to a new module virqemu.c and
rename the API to virQEMUBuildObjectCommandline.

This API will then be shareable with qemu-img and the need to build
a security object for luks support.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-06-06 13:44:51 -04:00
Ján Tomko
00c9877e77 qemu: always assume QEMU_CAPS_DRIVE_READONLY
We have been always setting the capability on if qemu has
QEMU_CAPS_DEVICE.
2016-05-23 10:35:44 +02: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
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
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
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
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
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
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
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
b12acd31af qemu: Introduce qemuBuildRNGCommandLine
Add new function to manage adding the RNG device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Also modify the qemuBuildRNGDevStr to use const virDomainDef instead
of virDomainDefPtr.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-15 07:10:22 -04:00
John Ferlan
00e47796a9 qemu: Introduce qemuBuildMemballoonCommandLine
Add new function to manage adding the memballoon device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Also modify the qemuBuildMemballoonDevStr to use const virDomainDef
instead of virDomainDefPtr.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-15 07:10:22 -04:00
John Ferlan
d2108df57c qemu: Introduce qemuBuildHostdevCommandLine
Add new function to manage adding the host device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Also modify qemuBuildPCIHostdevDevStr, qemuBuildUSBHostdevDevStr,
and qemuBuildSCSIHostdevDevStr to use const virDomainDef instead
of virDomainDefPtr.

Make qemuBuildPCIHostdevPCIDevStr and qemuBuildUSBHostdevUSBDevStr
static to the qemu_command.c.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-15 07:10:22 -04:00
John Ferlan
59e7ef3c1f qemu: Introduce qemuBuildRedirdevCommandLine
Add new function to manage adding the redirdev device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Also move the qemuBuildRedirdevDevStr closer to the new function and
modify to use the const virDomainDef instead of virDomainDefPtr

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-15 07:10:22 -04:00
John Ferlan
4666b762b9 qemu: Introduce qemuBuildWatchdogCommandLine
Add new function to manage adding the watchdog device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Also since qemuBuildWatchdogDevStr was only local here, make it static as
well as modifying the const virDomainDef.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-15 07:10:22 -04:00
John Ferlan
1a91ddb496 qemu: Introduce qemuBuildSoundCommandLine
Add new function to manage adding the sound device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Also since qemuBuildSoundDevStr was only local here, make it static as
well as modifying the const virDomainDef.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-15 07:10:22 -04:00
John Ferlan
60b1ff52f5 qemu: Introduce qemuBuildInputCommandLine
Add new function to manage adding the input device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Make qemuBuildUSBInputDevStr static since only this module calls it.

Also the change to use const virDomainDef forces other changes.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-11 19:23:46 -05:00
John Ferlan
5ab86400bf qemu: Introduce qemuBuildSerialCommandLine
Add new function to manage adding the serial device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Using const virDomainDef causes collateral damage in other called APIs
which need to make the similar adjustment

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-11 19:23:46 -05:00
John Ferlan
3dbc2a149f qemu: Introduce qemuBuildFSDevCommandLine
Add new function to manage adding the -fsdev options to the
command line removing that task from the mainline qemuBuildCommandLine.
Alter the code slightly to perform the !caps and fsdev failure check
up front.

Since both qemuBuildFSStr and qemuBuildFSDevStr are local, make them
static and fix their prototypes to use the const virDomainDef as well.
Make some minor formatting changes for long lines.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-11 06:31:05 -05:00
John Ferlan
0ea0f6c496 qemu: Introduce qemuBuildDiskDriveCommandLine
Add new function to manage adding the disk -drive options to the
command line removing that task from the mainline qemuBuildCommandLine.

Also since using const virDomainDef in new function, that means other
functions called needed to change their usage.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-11 06:17:06 -05:00
John Ferlan
f87be33a6f qemu: Introduce qemuBuildHubCommandLine
Add new function to manage adding the hub -device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Also make qemuBuildHubDevStr static to the module since it's only
used here.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-11 06:17:06 -05:00
John Ferlan
4908772e15 qemu: Introduce qemuBuildControllerDevCommandLine
Add new function to manage adding the controller -device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Also adjust to using const virDomainDef instead of virDomainDefPtr.
This causes collateral damage in order to modify called APIs to use
the const virDomainDef instead as well.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-11 06:17:06 -05:00
Daniel P. Berrange
3e12ec4a1e qemu: use virtlogd for character device log files
If use of virtlogd is enabled, then use it for backing the
character device log files too. This avoids the possibility
of a guest denial of service by writing too much data to
the log file.
2016-03-10 15:41:52 +00:00
Martin Kletzander
a89f05ba8d qemu: Shorten per-domain directory names
Per-domain directories were introduced in order to be able to
completely separate security labels for each domain (commit
f1f68ca334).  However when the domain
name is long (let's say a ridiculous 110 characters), we cannot
connect to the monitor socket because on length of UNIX socket address
is limited.  In order to get around this, let's shorten it in similar
fashion and in order to avoid conflicts, throw in an ID there as well.
Also save that into the status XML and load the old status XMLs
properly (to clean up after older domains).  That way we can change it
in the future.

The shortening can be seen in qemuxml2argv tests, for example in the
hugepages-pages2 case.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-01 07:15:29 +01:00
Cole Robinson
4b9fa11450 qemu: Move PORT definitions to qemu_conf.c
Which is the only user. That was the only reason for including
qemu_command.h, though we need to explicitly include qemu_domain.h
afterwards.
2016-02-17 11:07:21 -05:00
John Ferlan
731ed05ce9 qemu: Move qemuDomainNetVLAN
Move function into qemu_domain.c.
2016-02-16 11:07:48 -05:00
John Ferlan
de71e0e500 qemu: Move qemuAssign*Alias* API's into their own module
Create a new module qemu_alias.c to handle the qemuAssign*Alias* APIs
and the qemuDomainDeviceAliasIndex
2016-02-16 11:07:48 -05:00
John Ferlan
7edf0e5ef8 qemu: Move and rename qemuOpenVhostNet
Move function to qemu_interface.c and rename to qemuInterfaceOpenVhostNet

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-02-16 11:07:47 -05:00
John Ferlan
177db48734 qemu: Move qemuDomain*Address* functions
Create new modules qemu_domain_address.c and qemu_domain_address.h to
contain all the new functions and header data. Additionally move any
supporting static functions.

Make qemuDomainSupportsPCI non static.

Also, move and rename the following:

qemuSetSCSIControllerModel to qemuDomainSetSCSIControllerModel
qemuCollectPCIAddress to qemuDomainCollectPCIAddress
qemuValidateDevicePCISlotsPIIX3 to qemuDomainValidateDevicePCISlotsPIIX3
qemuAssignDevicePCISlots to qemuDomainAssignDevicePCISlots

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-02-16 11:07:47 -05:00
John Ferlan
a1a1e44798 qemu: Move qemuNetworkIfaceConnect to qemu_interface.c and rename
Move the misplaced function from qemu_command.c to qemu_interface.c
since it's closer in functionality there and had less to do with building
the command line.

Rename function to qemuInterfaceBridgeConnect and modify callers.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-02-16 11:07:47 -05:00
John Ferlan
5937241328 qemu: Move qemuPhysIfaceConnect to qemu_interface.c and rename
Move the misplaced function from qemu_command.c to qemu_interface.c
since it's closer in functionality there and had less to do with building
the command line.

Rename function to qemuInterfaceDirectConnect and modify callers.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-02-16 11:07:47 -05:00
John Ferlan
d860b2f537 qemu: Split the command parsing routines into own module
Extract out the qemuParseCommandLine{String|Pid} into their own
separate module - taking with it all the various static functions.

Causes a ripple effect with a few other modules to include the
new qemu_parse_command.h.

Narrowed down the list of #include's in the split out module to
those that are necessary for build.
2016-02-10 15:21:37 -05:00
Cole Robinson
92549b3b8a qemu: Mark some functions as static 2016-02-01 10:33:25 -05:00
Laine Stump
a8e3247e65 qemu: add bootindex option to hostdev network interface commandline
when appropriate, of course. If the config for a domain specifies boot
order with <boot dev='blah'/> elements, e.g.:

     <os>
       ...
       <boot dev='hd'/>
       <boot dev='network'/>
     </os>

Then the first disk device in the config will have ",bootindex=1"
appended to its qemu commandline -device options, and the first (and
*only* the first) network interface device will get ",bootindex=2".

However, if the first network interface device is a "hostdev" device
(an SRIOV Virtual Function (VF) being assigned to the domain with
vfio), then the bootindex option will *not* be appended. This happens
because the bootindex=n option corresponding to the order of "<boot
dev='network'/>" is added to the -device for the first network device
when network device commandline args are constructed, but if it's a
hostdev network device, its commandline arg is instead constructed in
the loop for hostdevs.

This patch fixes that omission by noticing (in bootHostdevNet) if the
first network device was a hostdev, and if so passing on the proper
bootindex to the commandline generator for hostdev devices - the
result is that ",bootindex=2" will be properly appended to the first
"network" device in the config even if it is really a hostdev
(including if it is assigned from a libvirt network pool). (note that
this is only the case if there is no <bootmenu enabled='yes'/> element
in the config ("-boot menu-on" in qemu) , since the two are mutually
exclusive - when the bootmenu is enabled, the individual per-device
bootindex options can't be used by qemu, and we revert to using "-boot
order=xyz" instead).

If a greater level of control over boot order is desired (e.g., more
than one network device should be tried, or a network device other
than the first one encountered in the config), then <boot
dev='network'/> in the <os> element should not be used; instead, the
individual device elements in the config should be given a "<boot
order='n'/>

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1278421
2015-12-15 10:57:27 -05:00
Michal Privoznik
81a110edc7 qemu: Enable multiqueue for macvtaps
https://bugzilla.redhat.com/show_bug.cgi?id=1240439

Ta-da! Now that we know how to open a macvtap device multiple
times, we can finally enable the multiqueue feature. Everything
else is already prepared (e.g. command line generation) from the
previous iteration where the feature was implemented for
TUN/TAP devices.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-12-11 08:44:44 +01:00
John Ferlan
a3c90fcb94 qemu: Fix build error in Coverity environment
Commit id '08600de37' changed the prototype to reduce an argument, but
didn't adjust the ATTRIBUTE_NONNULL(11) to (10)
2015-11-19 08:50:29 -05:00
Jiri Denemark
34b9fe6101 qemu: Move incoming URI code to qemu_migration
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-11-19 09:41:23 +01:00
Jiri Denemark
08600de376 qemu: Don't generate migration URI in qemuBuildCommandLine
Make callers of qemuBuildCommandLine responsible for providing the URI
which should be passed as a parameter for -incoming.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-11-19 09:41:23 +01:00
Peter Krempa
6f95618ed3 qemu: command: Move dimm device checks from formatter to checker
Aggregate the checks of the dimm device into the verification function
rather than having them in the formatter.
2015-11-18 10:32:18 +01:00