Commit Graph

16386 Commits

Author SHA1 Message Date
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
6af73f53c6 util: Introduce virRandomBytes
Using the existing virUUIDGenerateRandomBytes, move API to virrandom.c
rename it to virRandomBytes and add it to libvirt_private.syms.

This will be used as a fallback for generating a domain master key.
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
Guido Günther
12b239a9fa Link libvirt_xenconfig instead of libvirt against libxl
to avoid the test failure

 7) Test driver "xen"  ... 2016-03-31 12:53:26.950+0000: 22430: debug : virDriverLoadModule:54 : Module load xen
 2016-03-31 12:53:26.950+0000: 22430: error : virDriverLoadModule:73 : failed to load module /build/libvirt-1.3.3~rc1/debian/build/src/.libs/libvirt_driver_xen.so /build/libvirt-1.3.3~rc1/debian/build/src/.libs/libvirt_driver_xen.so: undefined symbol: xlu_cfg_destroy
FAILED
2016-04-06 20:26:59 +02:00
Ján Tomko
7f35b6b658 libvirt-admin: do not crash on URI without a scheme 2016-04-06 14:47:41 +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
Peter Krempa
836bf4ba7c conf: Pass the whole device info struct to virDomainDeviceBootParseXML
No need to extract the single element.
2016-04-06 09:27:23 +02:00
John Ferlan
0dc49e237a network: Remove extraneous ATTRIBUTE_NONNULL
Commit id '3992ff14' added the prototype for networkGetActualType
with 1 parameter, but added 2 ATTRIBUTE_NONNULL's (assume from a
cut-n-paste), just remove (2).
2016-04-05 05:43:47 -04: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
Martin Kletzander
17a94ba70f nodedev: Fix parsing of generated XMLs
Commit d77ffb6876 added not only reporting of the PCI header type, but
also parsing of that information.  However, because there was no parsing
done for the other sub-PCI capabilities, if there was any other
capability then a valid header type name (like phys_function or
virt_functions) the parsing would fail.  This prevented passing node
device XMLs that we generated into our own functions when dealing with,
e.g. with SRIOV cards.

Instead of reworking the whole parsing, just fix this one occurence and
remove a test for it for the time being.  Future patches will deal with
the rest.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-04-04 14:24:02 +02: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
Laine Stump
3992ff14e5 network: new function networkGetActualType
There are times when it's necessary to learn the actual type of a
network connection before any resources have been allocated
(e.g. during qemuProcessPrepareDomain()), but in the past it was
necessary to call networkAllocateActualDevice() in order to have the
actual type filled in.

This new function returns the type of network that *will be* setup
once it actually happens, but without making any changes on the host.
2016-04-04 07:03:12 -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
Guido Günther
dfbc9a8382 apparmor: QEMU monitor socket moved
The directory name changed in a89f05ba8d.

This unbreaks launching QEMU/KVM VMs with apparmor enabled. It also adds
the directory for the qemu guest-agent socket which is not known when
parsing the domain XML.
2016-04-02 12:49:28 +02:00
Andrea Bolognani
fbd4db79e4 Revert "hostdev: Use actual device when reattaching"
This reverts commit ee4cfb5643.

Since we're still not persisting our bookkeeping lists across
daemon restarts, we might have lost some information
virPCIDeviceReattach() relies on, for example whether the
device needs to be unbound from the stub driver.

As a result, if the daemon has been restarted in the meantime,
the device might end up remaining bound to the stub driver even
after 'virsh nodedev-reattach' or similar has been called, with
no way of giving it back to the host short of messing with
sysfs behind libvirt's back.

Revert back to the previous behavior of always trying to bind
the device to the host driver, regardless of its status when it
was detached, until persistent bookkeeping lists have been
implemented.
2016-04-01 17:06:53 +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
Jim Fehlig
ff825f9def libxl: fix net device detach
Chunyan sent a nice cleanup patch for libxlDomainDetachNetDevice

https://www.redhat.com/archives/libvir-list/2016-March/msg00926.html

which I incorrectly modified before pushing as commit b5534e53. My
modification caused network devices of type hostdev to no longer
be removed. This patch changes b5534e53 to resemble Chunyan's
original, correct patch.
2016-03-31 10:17:28 -06:00
Jim Fehlig
95d3c73871 libxl: fix attaching net device of type hostdev
Chunyan sent a correct patch to fix a resource leak on error in
libxlDomainAttachNetDevice

https://www.redhat.com/archives/libvir-list/2016-March/msg00924.html

I made what was thought to be an improvement and pushed the patch as
commit e6336442. As it turns out, my change broke adding net devices
that are actually hostdevs to the list of nets in virDomainDef. This
patch changes e6336442 to resemble Chunyan's original, correct
patch.
2016-03-31 10:17:28 -06:00
Fabiano Fidêncio
ab74e8763d build: workaround broken SASL header (again)
Compilation for xdg-app failed due to a buggy SASL headers present on
the used runtime (org.gnome.Sdk 3.18).

In file included from rpc/virnetsaslcontext.h:24:0,
                 from rpc/virnetsaslcontext.c:25:
/usr/include/sasl/sasl.h:230:38: error: unknown type name 'size_t'
 typedef void *sasl_realloc_t(void *, size_t);
                                      ^
/usr/include/sasl/sasl.h:235:5: error: unknown type name 'sasl_realloc_t'
     sasl_realloc_t *,

Use the same workaround as commit 1be3dfd did.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2016-03-31 17:36:49 +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
2cbdd64adf virPerfReadEvent: Prefer saferead over read
Do I really need to explain why?
Well, if read() is interrupted int the middle of reading, we will
never read the rest (even though it's highly unlikely as we are
reading just 8 bytes).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-31 17:25:21 +02:00
Martin Kletzander
c62e7702c0 remote: Add flags to remote_protocol-structs
Caused by 3b6c818532.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-31 14:07:46 +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
Michal Privoznik
46a5d1938e remoteDomainGetPerfEvents: Re-indent
There are few lines off the indentation.

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
Jim Fehlig
e23a640c42 libxl: only disable domain death events in libxlDomainCleanup
Remove disabling domain death events from libxlDomainStart error
path. The domain death event is already disabled in libxlDomainCleanup.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2016-03-29 14:16:31 -06:00
Chunyan Liu
45fc2c1436 libxl: fix resource leaks in libxlDomainStart error paths
libxlDomainStart allocates and reserves resources that were not
being released in error paths. libxlDomainCleanup already handles
the job of releasing resources, and libxlDomainStart should call
it when encountering a failure.

Change the error handling logic to call libxlDomainCleanup on
failure. This includes acquiring the lease sooner and allowing
it to be released in libxlDomainCleanup on failure, similar to
the way other resources are reclaimed. With the lease now
released in libxlDomainCleanup, the release_dom label can be
renamed to cleanup_dom to better reflect its changed semantics.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2016-03-29 14:16:31 -06:00
Jim Fehlig
a75e35a083 libxl: rename cleanup_dom label
Rename cleanup_dom label to destroy_dom, which better describes what
it does.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2016-03-29 14:16:31 -06:00
Peter Krempa
5c633e0f7b conf: Remove now unused virDomainIOThreadIDMap 2016-03-29 21:26:07 +02:00
Peter Krempa
0b4b58690d conf: decrease iterations complexity when formatting iothreads
Create a bitmap of iothreads that have scheduler info set so that the
transformation algorithm does not have to iterate the empty bitmap many
times. By reusing self-expanding bitmaps the bitmap size does not need
to be pre-calculated.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1264008
2016-03-29 21:26:06 +02:00
Peter Krempa
917426c8d7 util: bitmap: Introduce self-expanding bitmap APIs
In some cases it's impractical to use the regular APIs as the bitmap
size needs to be pre-declared. These new APIs allow to use bitmaps that
self expand.

The new code adds a property to the bitmap to track the allocation of
memory so that VIR_RESIZE_N can be used.
2016-03-29 21:25:41 +02:00
Roman Bogorodskiy
4ed5937d71 perf: fix build on non-Linux
* Sync stubbed functions with prototypes
 * Add missing ATTRIBUTE_UNUSED where needed

Pushing under the build breaker rule.
2016-03-29 19:26:47 +03: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
Peter Krempa
0ea4fd7a58 qemu: Kill qemuDiskPathToAlias
The function has terrible semantics. Split it into two functions.
2016-03-29 15:25:16 +02:00
Peter Krempa
9f7d9891f0 qemu: monitor: Remove JSON impls of drive_add and drive_del
qemu won't ever add those functions directly to QMP. They will be
replaced with 'blockdev-add' and 'blockdev-del' eventually. At this time
there's no need to keep the stubs around.

Additionally the drive_del stub in JSON contained dead code in the
attempt to report errors. (VIR_ERR_OPERATION_UNSUPPORTED was never
reported). Since the text impl does have the same message it is reported
anyways.
2016-03-29 15:25:16 +02:00
Peter Krempa
552bf13f45 qemu: monitor: Drop qemuMonitorAttachDrive and leaves in call tree
Functions no longer required for attaching SCSI disks since
QEMU_CAPS_DEVICE is expected.
2016-03-29 15:23:10 +02:00
Peter Krempa
d4d32005d6 qemu: hotplug: Assume support for -device in qemuDomainAttachSCSIDisk
We've started to assume support for QEMU_CAPS_DEVICE. Doing so in the
SCSI disk hotplug code allows us to drop a lot of ugly legacy code.
2016-03-29 15:20:44 +02:00
Maxim Nestratov
9b73aff033 bhyve: fix invalid hostsysinfo freeing 2016-03-29 15:58:07 +03:00
Maxim Nestratov
f999f77d7d bhyve: cleanup unnecessary variables 2016-03-29 15:57:54 +03:00
Qiaowei Ren
bf9bc04683 perf: reenable perf events when libvirtd restart
When libvirtd daemon restart, this patch will reenable those perf
events previously enabled.

Signed-off-by: Qiaowei Ren <qiaowei.ren@intel.com>
Message-id: 1459171833-26416-7-git-send-email-qiaowei.ren@intel.com
2016-03-29 13:13:05 +01:00
Qiaowei Ren
afe833e9bd perf: add new xml element
This patch adds new xml element, and so we can have the option of
also having perf events enabled immediately at startup.

Signed-off-by: Qiaowei Ren <qiaowei.ren@intel.com>
Message-id: 1459171833-26416-6-git-send-email-qiaowei.ren@intel.com
2016-03-29 13:13:05 +01:00
Qiaowei Ren
0dd0165c03 qemu_driver: add support to perf event
This patch implement the internal driver API for perf event into
qemu driver.

Signed-off-by: Qiaowei Ren <qiaowei.ren@intel.com>
Message-id: 1459171833-26416-5-git-send-email-qiaowei.ren@intel.com
2016-03-29 13:13:05 +01:00
Qiaowei Ren
28b446292b perf: implement a set of util functions for perf event
This patch implement a set of interfaces for perf event. Based on
these interfaces, we can implement internal driver API for perf,
and get the results of perf conuter you care about.

Signed-off-by: Qiaowei Ren <qiaowei.ren@intel.com>
Message-id: 1459171833-26416-4-git-send-email-qiaowei.ren@intel.com
2016-03-29 13:13:05 +01:00
Qiaowei Ren
dd00767cbd perf: implement the remote protocol for perf event
Add remote support for perf event.

Signed-off-by: Qiaowei Ren <qiaowei.ren@intel.com>
Message-id: 1459171833-26416-3-git-send-email-qiaowei.ren@intel.com
2016-03-29 13:13:05 +01:00
Qiaowei Ren
c803b0072b perf: add new public APIs for perf event
API agreed on in
https://www.redhat.com/archives/libvir-list/2015-October/msg00872.html

* include/libvirt/libvirt-domain.h (virDomainGetPerfEvents,
virDomainSetPerfEvents): New declarations.
* src/libvirt_public.syms: Export new symbols.
* src/driver-hypervisor.h (virDrvDomainGetPerfEvents,
virDrvDomainSetPerfEvents): New typedefs.
* src/libvirt-domain.c: Implement virDomainGetPerfEvents and
virDomainSetPerfEvents.

Signed-off-by: Qiaowei Ren <qiaowei.ren@intel.com>
Message-id: 1459171833-26416-2-git-send-email-qiaowei.ren@intel.com
2016-03-29 13:13:05 +01:00
Nitesh Konkar
3e19b5d53d storage: Initialize pool size parameters for refresh thread
If the pool creation thread happens to detect the luns in
the scsi target, the size parameters will be calculated as
part of the refreshPool called from storagePoolCreate().

This means the virStoragePoolFCRefreshThread (commit id
'512b874') waiting to run and "refresh" the pool will
essentially double the allocation and capacity values.
A separate refresh would correct the values.

To avoid this, the FCRefreshThread needs to reinitialize
the pool size values prior to calling virStorageBackendSCSIFindLUs
which eventually calls virStorageBackendSCSINewLun and
updates the size values for each volume found.
2016-03-29 07:28:47 -04:00
Peter Krempa
98033a8b94 storage: rbd: Fix build
After the recent commits the build didn't work for me. Fix it by
using size_t as the callback argument is using and the correct
formatter. The attempted fixup to use %llu as a formatter was wrong.
2016-03-29 08:51:33 +02:00
Jim Fehlig
33a1a7c6f5 libxl: remove reference to non-existent out label
Commit e6336442 changed the 'out:' label to 'cleanup'  in
libxlDomainAttachNetDevice(), but missed a comment referencing
the 'out:' label. Remove it from the comment since it is no
longer accurate anyhow.
2016-03-28 13:05:42 -06:00
Maxim Nestratov
7068b56c85 conf: qemu: Add support for more HyperV Enlightenment features
This patch adds support for "vpindex", "runtime", "synic",
"stimer", and "vendor_id" features available in qemu 2.5+.

- When Hyper-V "vpindex" is on, guest can use MSR HV_X64_MSR_VP_INDEX
to get virtual processor ID.

- Hyper-V "runtime" enlightement feature allows to use MSR
HV_X64_MSR_VP_RUNTIME to get the time the virtual processor consumes
running guest code, as well as the time the hypervisor spends running
code on behalf of that guest.

- Hyper-V "synic" stands for Synthetic Interrupt Controller, which is
lapic extension controlled via MSRs.

- Hyper-V "stimer" switches on Hyper-V SynIC timers MSR's support.
Guest can setup and use fired by host events (SynIC interrupt and
appropriate timer expiration message) as guest clock events

- Hyper-V "reset" allows guest to reset VM.

- Hyper-V "vendor_id" exposes hypervisor vendor id to guest.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-28 13:10:18 -04:00
Nikolay Shirokovskiy
2e26d78c8b conf: refactor hyperv features xml output
1. All hyperv features are tristate ones. So make tristate generating part common.
2. Reduce nesting on spinlocks.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-28 13:10:18 -04:00
Nikolay Shirokovskiy
ae37d9f1d1 conf: refactor hyperv features parsing
1. All hyperv features are tristate ones. So make tristate parsing code common.
2. Reindent switch statement.
3. Reduce nesting in spinlocks parsing.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-28 13:10:18 -04:00
Laine Stump
5b5f12cffa util: avoid getting stuck on macvtapN name created outside libvirt
After the patches that added tracking of in-use macvtap names (commit
370608, first appearing in libvirt-1.3.2), if the function to allocate
a new macvtap device came to a device name created outside libvirt, it
would retry the same device name MACVLAN_MAX_ID (8191) times before
finally giving up in failure.

The problem was that virBitmapNextClearBit was always being called
with "0" rather than the value most recently checked (which would
increment each time through the loop), so it would always return the
same id (since we dutifully release that id after failing to create a
new device using it).

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

Signed-off-by: Laine Stump <laine@laine.org>
2016-03-28 12:52:50 -04:00
Chunyan Liu
373b9e9f00 libxl: fix hot add/remove VF from a pool
For those VF allocated from a network pool, we need to set its backend
to be VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN so that later work can be
correct.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
2016-03-28 10:18:39 -06:00
Roman Bogorodskiy
b77cec09db Revert "zfs: Only raw volumes are supported"
This reverts commit bb5f2dc91f.

The "if (vol->target.format != VIR_STORAGE_FILE_RAW)" check in the
createVol backend. This check is bogus because virStorageVolDefParseXML()
in conf/storage_conf.c sets target.format only if volOptions in
virStoragePoolTypeInfo has formatFromString set, and that's not the
case the zfs backend.

So the check always fails and breaks volume creation.
2016-03-27 11:11:04 -04:00
Roman Bogorodskiy
139a319794 Revert "logical: Only raw volumes are supported"
This reverts commit 6682d6219d.

The "if (vol->target.format != VIR_STORAGE_FILE_RAW)" check in the
createVol backend. This check is bogus because virStorageVolDefParseXML()
in conf/storage_conf.c sets target.format only if volOptions in
virStoragePoolTypeInfo has formatFromString set, and that's not the
case the logical backend.

So the check always fails and breaks volume creation.
2016-03-27 11:09:53 -04:00
Chunyan Liu
420eff8f26 libxlDomainDetachDeviceLive: handle hostdev parent is network device
When hostdev parent is network device, should call
libxlDomainDetachNetDevice to detach the device from a higher level.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
2016-03-25 16:57:34 -06:00
Chunyan Liu
b5534e5391 libxlDomainDetachNetDevice: cleanup codes
Adjust codes to make it cleaner.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
2016-03-25 16:57:34 -06:00
Chunyan Liu
e633644229 libxlDomainAttachNetDevice: release actual deivce and remove hostdev when fail
When AttachNetDevice failed, should call networkReleaseActualDevice
to release actual device, and if actual device is hostdev, should
remove the hostdev from vm->def->hostdevs.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
2016-03-25 16:57:33 -06:00
Laine Stump
b41261f010 network: call proper start/stop functions for macvtap bridge-mode networks
networkStartNetwork() and networkShutdownNetwork() were calling the
wrong type-specific function in the case of networks that were
configured for macvtap ("direct") bridge mode - they were instead
calling the functions for a tap+bridge network. Currently none of
these functions does anything (they just return 0) so it hasn't
created any problems, but that could change in the future.
2016-03-25 13:28:34 -04:00
Laine Stump
2a537fe187 network: differentiate macvtap/bridge from host-bridge based networks
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1316465

An attempt to simplify the code for the VIR_NETWORK_FORWARD_BRIDGE
case of networkUpdateState in commit b61db335 (first in release
1.2.14) resulted in networks based on macvtap bridge mode being
erroneously marked as inactive any time libvirtd was restarted.

The problem is that the original code had differentiated between a
network using tap devices to connect to an existing host-bridge device
(forward mode of VIR_NETWORK_FORWARD_BRIDGE and a non-NULL
def->bridge), and one using macvtap bridge mode to connect to any
ethernet device (still forward mode VIR_NETWORK_FORWARD_BRIDGE, but
null def->bridge), but the changed code assumed that all networks with
VIR_NETWORK_FORWARD_BRIDGE were tap + host-bridge networks, so a null
def->bridge was interpreted as "inactive".

This patch restores the original code in networkUpdateState
2016-03-25 13:21:29 -04:00
Christophe Fergeau
7114c5ff25 storage/rbd: Use correct printf-modifier for uint64
%zu is for size_t variables, not uint64 ones. This causes a warning when building on
a 32 bit linux.
2016-03-25 09:04:46 -04:00
Jovanka Gulicoska
3e5b35a538 qemu: Replace some VIR_ERROR with vir*Error
qemuStateInitialize uses a mix of VIR_ERROR and standard vir*Error
calls. Prefer the standard vir*Error
2016-03-24 14:13:21 -04:00
Jovanka Gulicoska
2c20574d5b qemu: Don't duplicate virGetLastErrorMessage
These uses of virGetLastError message are just duplicating
virGetLastErrorMessage.
2016-03-24 14:04:18 -04:00
Erik Skultety
cd000d3a0b virlog: Refactor virLogParseFilters
Patch 0b231195 refactored logging output parser to make it more readable.
This patch does similar thing to logging filter parser.
2016-03-24 16:39:28 +01:00
Michal Privoznik
9b48ef9c51 gendispatch: Avoid comparing signed and unsigned vars
The adminDispatchConnectListServers() function is generated by
our great perl script. However, it has a tiny flaw: if
adminConnectListServers() it calls fails, the control jumps onto
cleanup label where we try to free any list of servers built so
far. However, in the loop @i is unsigned (size_t) while @nresults
is signed (int). Currently, it does no harm because of the check
for @result being non-NULL. But if that ever changes in the
future, this bug will be hard to chase.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-24 10:49:39 +01:00
Vasiliy Tolstov
9c17d665fd autocreate tap device for ethernet network type
If a user specify network type ethernet, then create it via libvirt and run
script if it provided. After this commit user does not need to
run external script to create tap device or add root permissions to qemu
process.

Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
2016-03-23 11:37:59 +00:00
Andrea Bolognani
ee4cfb5643 hostdev: Use actual device when reattaching
Instead of forcing the values for the unbind_from_stub, remove_slot
and reprobe properties, look up the actual device and use that when
calling virPCIDeviceReattach().

This ensures the device is restored to its original state after
reattach: for example, if it was not bound to any driver before
detach, it will not be bound forcefully during reattach.
2016-03-23 11:38:20 +01:00
Andrea Bolognani
c3e2f6e37d hostdev: Save netdev configuration of actual device
We would be just fine looking up the information in pcidevs most
of the time; however, some corner cases would not be handled
properly, so look up the actual device instead.
2016-03-23 11:38:20 +01:00
Andrea Bolognani
811286090f hostdev: Streamline device ownership tracking
After this patch, ownership of virPCIDevice instances is very easy
to keep track of: for each host PCI device, the only instance that
actually matters is the one inside one of the bookkeeping list.

Whenever some operation needs to be performed on a PCI device, the
actual device is looked up first; when this is not the case, a
comment explains the reason.
2016-03-23 11:38:14 +01:00
Andrea Bolognani
6da6bf2f30 hostdev: Stop early if unmanaged devices have not been detached
Unmanaged devices, as the name suggests, are not detached
automatically from the host by libvirt before being attached to a
guest: it's the user's responsability to detach them manually
beforehand. If that preliminary step has not been performed, the
attach operation can't complete successfully.

Instead of relying on the lower layers to error out with cryptic
messages such as

  error: Failed to attach device from /tmp/hostdev.xml
  error: Path '/dev/vfio/12' is not accessible: No such file or directory

prevent the situation altogether and provide the user with a more
useful error message.
2016-03-23 10:58:18 +01:00
Andrea Bolognani
df490e7c9b hostdev: Detect untracked inactive devices
Unmanaged devices are attached to guests in two steps: first,
the device is detached from the host and marked as inactive;
subsequently, it is marked as active and attached to the guest.

If the daemon is restarted between these two operations, we lose
track of the inactive device.

Steps 5 and 6 of virHostdevPreparePCIDevices() already subtly
take care of this situation, but some planned changes will make
it so that's no longer the case. Plus, explicit is always better
than implicit.
2016-03-23 10:58:11 +01:00
Pavel Hrdina
12de369aa6 qemu_driver: cleanup qemuConnectDomainXMLToNative
Use qemuProcessCreatePretendCmd instead duplicating required steps from
qemuProcessStart.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-22 15:15:48 +01:00
Pavel Hrdina
758cca88b2 qemu_process: introduce qemuProcessCreatePretendCmd
This will skip few steps from qemuProcessStart in order to create only
qemu CMD.  Use a VIR_QEMU_PROCESS_START_PRETEND for all the qemuProcess*
functions called by this one to not modify or check host.

This new function will be used later on for XMLToNative API and also for
qemuxml2argvtest to make sure that both API and test uses the same code
as qemuProcessStart.

We need also update qemuProcessInit to wrap few lines of code with check
that VIR_QEMU_PROCESS_START_PRETEND that makes sense only for
qemuProcessStart.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-22 15:15:48 +01:00
Pavel Hrdina
6e8266ade5 qemu_process: move qemuDomainSetPrivatePaths to qemuProcessInit
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-22 15:15:48 +01:00
Pavel Hrdina
1e38ef728c qemu_process: move checks to qemuProcessStartValidate
Move all code that checks host and domain.  Do not check host if we use
VIR_QEMU_PROCESS_START_PRETEND flag.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-22 15:15:48 +01:00
Pavel Hrdina
a431d3440f qemu: update callers of qemuProcessStartValidate to use virDomainObjPtr
This change is required by following patches.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-22 15:15:48 +01:00
Pavel Hrdina
ddc0e6bcdc qemu_process: introduce qemuProcessPrepareHost
Move all code that modifies host system to this function.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-22 15:15:48 +01:00
Pavel Hrdina
f8e712feb4 qemu_process: introduce qemuProcessPrepareDomain
Move all code that modifies only live XML to this function.  The new
VIR_QEMU_PROCESS_START_PRETEND flag will be used by qemuXMLToNative and
qemuxml2argvtest later in order to reuse the same code as
qemuProcessStart uses.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-22 15:15:48 +01:00