Commit Graph

28130 Commits

Author SHA1 Message Date
Andrea Bolognani
46084f2aa1 conf: Improve virDomainChrTargetDefFormat()
Make the switch statement type-aware, avoid calling
virDomainChrTargetTypeToString() more than once and check its
return value before using it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-28 15:46:32 +01:00
Andrea Bolognani
2cd323e382 conf: Check virDomainChrSourceDefFormat() return value
The function can fail, but none of the caller were accounting
for that.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-28 15:46:32 +01:00
Andrea Bolognani
be956c4e38 conf: Improve error handling in virDomainChrDefFormat()
We don't need to store the return value since we never modify it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-28 15:46:32 +01:00
Andrea Bolognani
00b7f81fa8 conf: Introduce virDomainChrTargetDefFormat()
Move formatting of the <target/> element for char devices out of
virDomainChrDefFormat() and into its own function.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-28 15:46:32 +01:00
Andrea Bolognani
4fb8ff9987 conf: Drop virDomainChrDeviceType.targetTypeAttr
This attribute was used to decide whether to format the type
attribute of the <target> element, but the logic didn't take into
account all possible cases and as such could lead to unexpected
results. Moreover, it's one more thing to keep track of, and can
easily fall out of sync with other attributes.

Now that we have VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE, we can
use that value to signal that no specific target type has been
configured for the serial device and as such the attribute should
not be formatted at all. All other values are now formatted.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-28 15:46:32 +01:00
Andrea Bolognani
6385c8c142 conf: Introduce VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_NONE
This is the first step in getting rid of the assumption that
isa-serial is the default target type for serial devices.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-28 15:46:32 +01:00
Andrea Bolognani
2628afc143 conf: Run devicePostParse() again for the first serial device
The devicePostParse() callback is invoked for all devices so that
drivers have a chance to set their own specific values; however,
virDomainDefAddImplicitDevices() runs *after* the devicePostParse()
callbacks have been invoked and can add new devices, in which case
the driver wouldn't have a chance to customize them.

Work around the issue by invoking the devicePostParse() callback
after virDomainDefAddImplicitDevices(), only for the first serial
devices, which might have been added by it. The same was already
happening for the first video device for the very same reason.

This will become important later on, when we will change
virDomainDefAddConsoleCompat() not to set a targetType for
automatically added serial devices.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-28 15:46:31 +01:00
Andrea Bolognani
f4b50cc1b9 qemu: Introduce qemuDomainChrDefPostParse()
Having a separate function for char device handling is better than
adding even more code to qemuDomainDeviceDefPostParse().

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
2017-11-28 15:46:31 +01:00
Andrea Bolognani
4567cecb37 docs: Improve documentation for serial consoles
Our current documentation is missing some information and doesn't
do a great job at explaining how the <serial> and <console> elements
are connected. Let's try to fix that.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-28 15:46:31 +01:00
Peter Krempa
c32fda72e3 news: Document qemu image locking 2017-11-27 14:02:19 +01:00
Julio Faracco
13d45b0dc2 virsh: Fix virsh prompt when connection changes to readonly mode.
This commit fixes the virsh prompt when reconnection to the same URI is
called: `virsh # connect --readonly` (Reconnect). The problem is
happening because the code is considering URI (name) as a mandatory
parameter to change the prompt. This commit remove the assignment into
`priv->readonly` from `if (name)` conditional.

Before:
    virsh # uri
    qemu:///system

    virsh # connect --readonly

    virsh #

After:
    virsh # uri
    qemu:///system

    virsh # connect --readonly

    virsh >

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

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2017-11-27 10:12:30 +01:00
John Ferlan
8ed2b6300b docs: Add news article to describe iSCSI usage of secret object 2017-11-24 11:47:26 -05:00
John Ferlan
44516750b3 docs: Add news article regarding auth/encryption placement 2017-11-24 11:47:26 -05:00
John Ferlan
c5c96545c7 qemu: Use secret objects to pass iSCSI passwords
https://bugzilla.redhat.com/show_bug.cgi?id=1425757

The blockdev-add code provides a mechanism to sanely provide user
and password-secret arguments for iscsi without placing them on the
command line to be viewable by a 'ps -ef' type command or needing
to create separate -iscsi devices for each disk/volume found.

So modify the iSCSI command line building to check for the presence
of the capability in order properly setup and use the domain master
secret object to encrypt the password in a secret object and alter
the parameters for the command line to utilize.

Modify the xml2argvtest to exhibit the syntax for both disk and
hostdev configurations.
2017-11-24 11:47:26 -05:00
John Ferlan
4f44b8b5ae qemu: Get capabilities to use iscsi password-secret argument
Detect the capability via the query-qmp-schema for blockdev-add
to find the 'password-secret' parameter that will allow the iSCSI
code to use the master secret object to encrypt the secret for an
and only need to provide the object id of the secret on the command
line thus obsfuscating the passphrase.
2017-11-24 11:47:26 -05:00
John Ferlan
8001c2f3e4 qemu: Refactor qemuBuildSCSIiSCSIHostdevDrvStr slightly
Rather than building the "file" string in qemuBuildSCSIHostdevDrvStr
build it in the called helper.
2017-11-24 11:47:26 -05:00
John Ferlan
1d9108cf16 qemu: Remove private hostdev
Since it's not longer used to shuttle the @secinfo, let's remove
the private hostdev completely.
2017-11-24 11:47:26 -05:00
John Ferlan
16eef5c2b4 qemu: Use private storage source for iscsi instead of private hostdev
Rather than placing/using privateData about secinfo in the hostdev,
let's use the virStorageSource private data instead.
2017-11-24 11:47:26 -05:00
John Ferlan
626ea2d596 conf,qemu: Replace iscsisrc fields with virStorageSourcePtr
Rather than picking apart the two pieces we need/want (path, hosts,
and auth)- let's allocate/use a virStorageSourcePtr for iSCSI storage.

The end result is that qemuBuildSCSIiSCSIHostdevDrvStr doesn't need
to "fake" one for the qemuBuildNetworkDriveStr call.
2017-11-24 11:47:26 -05:00
Ján Tomko
2814f66f28 qemu: Properly label and create evdev on input device hotplug
Utilize all the newly introduced function to create the evdev node
and label it on hotplug and destroy it on hotunplug.

This was forgotten in commits bc9ffaf and 67486bb.

https://bugzilla.redhat.com/show_bug.cgi?id=1509866
2017-11-24 17:38:51 +01:00
Ján Tomko
c4c7a18c4b qemu: functions for dealing with input device namespaces and labels
Introudce functions that will let us create the evdevs in namespaces
and label the devices on input device hotplug/hotunplug.
2017-11-24 17:38:51 +01:00
Ján Tomko
f29612fd35 qemu: Introduce functions for input device cgroup manipulation
Export qemuSetupInputCgroup and introduce qemuTeardownInputCgroup
for hotunplug.
2017-11-24 17:38:51 +01:00
Ján Tomko
d8116b5a0a security: Introduce functions for input device hot(un)plug
Export the existing DAC and SELinux for separate use and introduce
functions for stack, nop and the security manager.
2017-11-24 17:38:51 +01:00
Ján Tomko
cbf4242db7 Introduce virDomainInputDefGetPath
Use it to denadify qemuDomainSetupInput.
2017-11-24 17:38:51 +01:00
Jason J. Herne
74fc32a955 s390: qemu-capabilities: Avoid error message when missing non-kvm host cpu info
Libvirt prints an error on startup when it is missing host cpu model
information for any queried qemu binary. On s390 we only have host cpu model
information for kvm enabled qemu instances. So when virt type is not kvm, this
is actually not an error on s390.

This patch adds virt type as a parameter to virQEMUCapsInitCPUModelS390, and a
new return code 2 for virQEMUCapsInitCPUModel and virQEMUCapsInitCPUModelS390.
If the virt type is not kvm then we skip printing the scary error message
and return 2 because this case is actually expected behavior. The new return
code is meant to differentiate between the failure case and the case where we
simply expect the cpu model information to be unattainable.

Signed-off-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-11-24 16:53:56 +01:00
John Ferlan
6caf67f834 storage: Fix broken storage_driver build
Commit id '5d5c732d7' had an incorrect assignment and was found
by travis build:

storage/storage_driver.c:1668:14: error: equality comparison with extraneous
      parentheses [-Werror,-Wparentheses-equality]
    if ((obj == virStoragePoolObjListSearch(&driver->pools,

         ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2017-11-24 09:42:07 -05:00
John Ferlan
dcb5d8bb13 storage: Convert virStoragePoolObj into virObjectLockable
Now that we're moved the object into virstorageobj, let's make the
code use the lockable object.
2017-11-24 08:08:36 -05:00
John Ferlan
5d5c732d74 storage: Introduce virStoragePoolObjListSearch
Create an API to search through the storage pool objects looking for
a specific truism from a callback API in order to return the specific
storage pool object that is desired.
2017-11-24 08:08:32 -05:00
John Ferlan
d0258dd9d6 storage: Introduce virStoragePoolObjListForEach
Create an API to walk the pools->objs[] list in order to perform a
callback function for each element of the objs array that doesn't care
about whether the action succeeds or fails as the desire is to run the
code over every element in the array rather than fail as soon as or if
one fails.
2017-11-24 07:26:06 -05:00
John Ferlan
770aa08e48 storage: Introduce virStoragePoolObjEndAPI
For now it'll just call the virStoragePoolObjUnlock, but a future
adjustment will do something different. Since the new API will check
for a NULL object before the Unlock call, callers no longer need to
check for NULL before calling.

The virStoragePoolObjUnlock is now private/static to virstorageobj.c
with a short term forward reference.
2017-11-24 07:26:06 -05:00
John Ferlan
9bfcf3ccdd nodedev: Restore setting of privileged
Commit id '36555364' removed the setting of the driver->privileged,
which the udevProcessPCI would need in order to read the PCI device
configs.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-11-24 07:17:37 -05:00
Peter Krempa
1455a91b33 qemu: command: Properly format disk 'debug' attribute
Move the setup of the disk attribute to the disk source prepare function
which will allow proper usage with JSON props and move the fallback
(legacy) generating code into the block which is executed with legacy
options.

As a side-effect of this change we can clean up propagation of 'cfg'
into the command generator.

Also it's nice to see that the test output is the same even when the
value is generated in a different place.
2017-11-23 18:50:04 +01:00
Peter Krempa
be50137aa0 qemu: domain: Unify disk source prepare steps
Aggregate setup of various aspects of a disk source (secrets, TLS, ...)
into one function so that we don't need to call multiple across the code
base.
2017-11-23 18:50:04 +01:00
Peter Krempa
7aa8a9a621 qemu: hotplug: Rename qemuDomainPrepareDisk to qemuHotplugPrepareDiskAccess
Match the prefix of the file and choose a name which better describes
what happens.
2017-11-23 18:50:04 +01:00
Peter Krempa
eeaf6657f7 qemu: block: Add support for formatting gluster debug level via JSON
Improve the formatter so that we can use the 'debug' property straight
away when using json.
2017-11-23 18:50:04 +01:00
Peter Krempa
0a1870ddd0 util: storage: Add fields for debug options for disk drivers
Some drive backends allow output of debugging information which can be
configured using properties of the image. Add fields to virStorageSource
which will allow configuring them.
2017-11-23 18:50:04 +01:00
Peter Krempa
6197d5726b qemu: command: Inject password-secret only when not using JSON props
The 'file.password-secret' injection should be used only if we are using
the old formatter. When formatting the source string from the JSON
properties, the property should be added there.

Also drop the comment which refers to stuff that will not be used in
libvirt since -blockdev is the way to go.
2017-11-23 18:50:04 +01:00
Michal Privoznik
f7deea5242 tools: Work around ancient readline
My latest commit of a785186446 uncovered a problem we fixed
in 9eb23fe2 but then reverted in 834c5720e4. Turns out, some
systems (I'm looking at you OS X) have ancient readline with
broken header file.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-11-23 18:37:17 +01:00
Peter Krempa
28907b0043 qemu: command: Mark <shared/> disks as such in qemu
Qemu has now an internal mechanism for locking images to fix specific
cases of disk corruption. This requires libvirt to mark the image as
shared so that qemu lifts certain restrictions.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1378242
2017-11-23 18:26:48 +01:00
Peter Krempa
860a3c4bea qemu: caps: Add capability for 'share-rw' disk option
'share-rw' for the disk device configures qemu to allow concurrent
access to the backing storage.

The capability is checked in various supported disk frontend buses since
it does not make sense to partially backport it.
2017-11-23 18:26:48 +01:00
Peter Krempa
2b41c86294 qemu: Disallow pivot of shared disks to unsupported storage
Pivoting to a unsupported storage type might break the assumption that
shared disks will not corrupt metadata.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1511480
2017-11-23 18:26:48 +01:00
Peter Krempa
9b2fbfa6f6 qemu: snapshot: Disallow snapshot of unsupported shared disks
Creating a snapshot would introduce a possibly unsupported member for
sharing into the backing chain. Add a check to prevent that from
happening.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1511480
2017-11-23 18:26:48 +01:00
Peter Krempa
3b03a27cd0 qemu: domain: Reject shared disk access if backing format does not support it
Disk sharing between two VMs may corrupt the images if the format driver
does not support it. Check that the user declared use of a supported
storage format when they want to share the disk.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1511480
2017-11-23 18:26:25 +01:00
Peter Krempa
1fc3cd8731 qemu: block: Add function to check if storage source allows concurrent access
Storage source format backing a shared device (e.g. running a cluster
filesystem) needs to support the sharing so that metadata are not
corrupted. Add a central function for checking this.
2017-11-23 18:26:25 +01:00
Peter Krempa
85b0e2f126 qemu: domain: Refactor domain device validation function
Use a style that will discourage from adding inline checks.
2017-11-23 18:26:25 +01:00
Peter Krempa
ab948b6299 qemu: domain: Move video device validation into separate function 2017-11-23 18:26:25 +01:00
Peter Krempa
a6936ec098 qemu: domain: Move hostdev validation into separate function 2017-11-23 18:26:25 +01:00
Peter Krempa
577ccd07c3 qemu: domain: Despaghettify qemuDomainDeviceDefValidate
Move network device validation into a separate function.
2017-11-23 18:26:14 +01:00
Peter Krempa
8ffdeed455 qemu: Move snapshot disk validation functions into one
Move the code so that both the new image and old image can be verified
in the same function.
2017-11-23 18:22:19 +01:00
Julio Faracco
d602a5f28a tests: changing network interface types when backend tag is defined.
Some test cases have the backend tag inside wrong interfaces. The backend xml
tag does not support <interface type='user|direct|hostdev'>. So this commit
changes some network types inside the interfaces that have backend defined.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
2017-11-23 17:43:13 +01:00