Commit Graph

21040 Commits

Author SHA1 Message Date
Jim Fehlig
5b74103b0b Xen: support maxvcpus in xm and xl config
From: Ian Campbell <ian.campbell@citrix.com>

xend prior to 4.0 understands vcpus as maxvcpus and vcpu_avail
as a bit map of which cpus are online (default is all).

xend from 4.0 onwards understands maxvcpus as maxvcpus and
vcpus as the number which are online (from 0..N-1). The
upstream commit (68a94cf528e6 "xm: Add maxvcpus support")
claims that if maxvcpus is omitted then the old behaviour
(i.e. obeying vcpu_avail) is retained, but AFAICT it was not,
in this case vcpu==maxcpus==online cpus. This is good for us
because handling anything else would be fiddly.

This patch changes parsing of the virDomainDef maxvcpus and vcpus
entries to use the corresponding 'maxvcpus' and 'vcpus' settings
from xm and xl config. It also drops use of the old Xen 3.x
'vcpu_avail' setting.

The change also removes the maxvcpus limit of MAX_VIRT_VCPUS (since
maxvcpus is simply a count, not a bit mask), which is particularly
crucial on ARM where MAX_VIRT_CPUS == 1 (since all guests are
expected to support vcpu placement, and therefore only the boot
vcpu's info lives in the shared info page).

Existing tests adjusted accordingly, and new tests added for the
'maxvcpus' setting.
2015-12-18 17:52:00 -07:00
John Ferlan
2eba5c5635 virsh: Add --delete-snapshots flag for undefine and vol-delete
https://bugzilla.redhat.com/show_bug.cgi?id=1281710

Commit id '3c7590e0a' added the flag to the rbd backend, but provided
no means via virsh to use the flag.  This patch adds a '--delete-snapshots'
option to both the "undefine" and "vol-delete" commands.

For "undefine", the flag is combined with the "--remove-all-storage" flag
in order to add the appropriate flag for the virStorageVolDelete call;
whereas, for the "vol-delete" command, just the flag is sufficient since
it's only operating on one volume.

Currently only supported for rbd backends.
2015-12-18 10:51:08 -05:00
John Ferlan
7d792b99b8 libvirt: Add virStorageVolDeleteFlags to virStorageVolDelete
Although they've been present for quite a while, they weren't added
to the API definition, so add them there to make it clearer.

Currently only the RBD backend even checks for any flags.
2015-12-18 10:51:08 -05:00
John Ferlan
be783825af storage: Add virCheckFlags to virStorageBackendRBDDeleteVol
The initial commit '74951eade' did not include the proper check for whether
any flags are supported by the driver.

Even though the driver doesn't support VIR_STORAGE_VOL_DELETE_ZEROED,
it still checks and allows the processing to continue

Also add the new VIR_STORAGE_VOL_DELETE_WITH_SNAPSHOTS since it is handled
as of commit id '3c7590e0a'.
2015-12-18 10:51:08 -05:00
John Ferlan
ae09988eb7 lxc_cgroup: Add check for NULL cgroup before AddTask call
Commit id '71ce4759' altered the cgroup processing with respect to the
call to virCgroupAddTask being moved out from lower layers into the calling
layers especially for qemu processing of emulator and vcpu threads. The
movement affected lxc insomuch as it is possible for a code path to
return a NULL cgroup *and* a 0 return status via virCgroupNewPartition
failure when virCgroupNewIgnoreError succeeded when virCgroupNewMachineManual
returns. Coverity pointed out that would cause virCgroupAddTask to core.

This patch will check for a NULL cgroup as well as the negative return
and just return the NULL cgroup to the caller (as it would have previously)
2015-12-18 08:59:34 -05:00
Jim Fehlig
be08842e47 Xen: remove xendConfigVersion from driver private struct
xendConfigVersion is no longer used, so remove it from the
xenUnifiedPrivate struct.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-12-17 21:28:48 -07:00
Jim Fehlig
60ac2aa821 Xen: xenconfig: remove xendConfigVersion from public sexpr functions
Remove use of xendConfigVersion in the s-expresion config formatter/parser
in src/xenconfig/. Adjust callers in the xen and libxl drivers accordingly.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-12-17 21:28:48 -07:00
Jim Fehlig
b6fa951897 Xen: xend: remove use of XEND_CONFIG_VERSION
Remove use of XEND_CONFIG_VERSION_* in xend_internal.c

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-12-17 21:28:47 -07:00
Jim Fehlig
64d14daa4b Xen: xen_driver: remove use of XEND_CONFIG_VERSION
Remove use of XEND_CONFIG_VERSION_* in the Xen unified driver.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-12-17 21:28:29 -07:00
Jim Fehlig
5ff2e370af Xen: xenconfig: remove use of XEND_CONFIG_VERSION in xen_sxpr
Remove use of XEND_CONFIG_VERSION_* in s-expression parser/formatter.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-12-17 21:22:34 -07:00
Jim Fehlig
f2b4a65728 Xen: tests: use latest XEND_CONFIG_VERSION in xml2sexpr tests
Change all xml2sexpr tests to use the latest XEND_CONFIG_VERSION
(XEND_CONFIG_VERSION_3_1_0 = 4). Fix tests that do not conform to
the latest version.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-12-17 21:22:34 -07:00
Jim Fehlig
bec993d60a Xen: xenconfig: remove disks from '(image)' sexpr
It has been quite some time since xend required specifying cdroms
and fds in '(image (hvm ...))'. Remove the code from the parsing
and formatting functions and fixup the associated tests.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-12-17 21:22:34 -07:00
Jim Fehlig
87dce7a762 Xen: tests: use latest XEND_CONFIG_VERSION in sexpr2xml tests
Change all sexpr2xml tests to use the latest XEND_CONFIG_VERSION
(XEND_CONFIG_VERSION_3_1_0 = 4). Fix tests that do not conform to
the latest version.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-12-17 21:22:33 -07:00
Jim Fehlig
7d7c08be1c Xen: xenconfig: remove xendConfigVersion from public functions
Remove use of xendConfigVersion in the xm and xl config formatter/parsers
in src/xenconfig/. Adjust callers in the xen and libxl drivers accordingly.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-12-17 21:22:33 -07:00
Jim Fehlig
0f58db3092 Xen: xenconfig: remove use of XEND_CONFIG_VERSION in xen_xm
Remove use of XEND_CONFIG_VERSION_* in xm parser/formatter.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-12-17 21:22:33 -07:00
Jim Fehlig
4796d7b34b Xen: xenconfig: remove XEND_CONFIG_VERSION in common code
Remove use of XEND_CONFIG_VERSION_* from xenconfig/xen_common.c

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-12-17 21:22:33 -07:00
Jim Fehlig
9e6d721985 Xen: tests: use latest XEND_CONFIG_VERSION in xm/xl tests
Change all tests to use the latest XEND_CONFIG_VERSION
(XEND_CONFIG_VERSION_3_1_0 = 4). Fix tests that do not conform to
the latest version.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-12-17 21:22:33 -07:00
Jim Fehlig
134e05e005 Xen: tests: remove old xml2sexpr tests
Remove XML to s-expression converstion tests for old xend 3.0.2
config format.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-12-17 21:22:33 -07:00
Jim Fehlig
ed5cf72035 Xen: tests: remove old sexpr2xml tests
Remove s-expression to XML conversion tests for old xend 3.0.2
config format.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-12-17 21:22:33 -07:00
Jim Fehlig
f281926e1d Xen: tests: remove net-ioemu xm config test
Remove the fullvirt-net-ioemu test since explicitly specifying
'type=ioemu' has not been needed in xm/xend for a long time. It is
not used at all in xl/libxl.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-12-17 21:22:33 -07:00
Jim Fehlig
59baedd87f Xen: tests: remove old xm config tests
Remove xm config tests for old xend 3.0.2 config format.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-12-17 21:22:33 -07:00
John Ferlan
e193735450 virsh: Add build flags to pool-create[-as] and pool-start
https://bugzilla.redhat.com/show_bug.cgi?id=830056

Utilize recently added VIR_STORAGE_POOL_CREATE_WITH_BUILD* flags in
order to pass the flags along to the virStoragePoolCreateXML and
virStoragePoolCreate API's.

This affects the 'virsh pool-create', 'virsh pool-create-as', and
'virsh pool-start' commands.  While it could be argued that pool-start
doesn't need the flags, they could prove useful for someone trying to
do one command build --overwrite and start command processing or
essentially starting with a clean slate.

NB:
This patch is loosely based upon code originally authored by Osier
Yang that were not reviewed and pushed, see:

https://www.redhat.com/archives/libvir-list/2012-July/msg00497.html
2015-12-17 11:56:18 -05:00
John Ferlan
5372d49b11 virsh: Create a macro for pool-define-as and pool-create-as options
Although they both are the same now, a future patch will add new options
to pool-create-as. So create a common macro to capture commonality, then
use that in the command specific structure.
2015-12-17 11:56:18 -05:00
John Ferlan
f9a6110f26 virsh: Create macro for "overwrite" and no-overwrite" options
Although not currently used in more than one command, it soon will be
so create a common macro to be used in the new command location.

Additionally, add the ".flags = 0," for both to match the expections
of the structure being predefined.
2015-12-17 11:56:18 -05:00
John Ferlan
e178688f8e virsh: Create macro for "file" option
Rather than continually cut/paste the "file" option for pool command
option structures, generate a macro which will commonly define it for
any command.  Then of course use that macro.
2015-12-17 11:56:18 -05:00
John Ferlan
cf793b0042 virsh: Create macro for "pool" option
Rather than continually cut/paste the "pool" option for pool command
option structures, generate a macro which will commonly define it for
any command.  Then of course use that macro.
2015-12-17 11:56:18 -05:00
John Ferlan
aeb1078ab5 storage: Add flags to allow building pool during create processing
https://bugzilla.redhat.com/show_bug.cgi?id=830056

Add flags handling to the virStoragePoolCreate and virStoragePoolCreateXML
API's which will allow the caller to provide the capability for the storage
pool create API's to also perform a pool build during creation rather than
requiring the additional buildPool step. This will allow transient pools
to be defined, built, and started.

The new flags are:

    * VIR_STORAGE_POOL_CREATE_WITH_BUILD
      Perform buildPool without any flags passed.

    * VIR_STORAGE_POOL_CREATE_WITH_BUILD_OVERWRITE
      Perform buildPool using VIR_STORAGE_POOL_BUILD_OVERWRITE flag.

    * VIR_STORAGE_POOL_CREATE_WITH_BUILD_NO_OVERWRITE
      Perform buildPool using VIR_STORAGE_POOL_BUILD_NO_OVERWRITE flag.

It is up to the backend to handle the processing of build flags. The
overwrite and no-overwrite flags are mutually exclusive.

NB:
This patch is loosely based upon code originally authored by Osier
Yang that were not reviewed and pushed, see:

https://www.redhat.com/archives/libvir-list/2012-July/msg01328.html
2015-12-17 11:56:18 -05:00
Ján Tomko
22f9754f1b mark virDomainVirtioSerialAddrSetAddController as static.
This function is no longer used outside domain_addr.c
2015-12-17 16:57:25 +01:00
Ján Tomko
36d7a36158 Remove dead code from qemuDomainAttachControllerDevice
We only support hotplugging SCSI controllers.
The USB and virtio-serial related code was never reachable because
this function was only called for VIR_DOMAIN_CONTROLLER_TYPE_SCSI
controllers.

This reverts commit ee0d97a and parts of commits 16db8d2
and d6d54cd1.
2015-12-17 16:57:25 +01:00
Ján Tomko
aaa42d905a qemu_hotplug: remove qemuDomainAttachDeviceControllerLive
This function calls qemuDomainAttachControllerDevice for SCSI
controllers and reports an error for all other controllers.

Move the error inside qemuDomainAttachControllerDevice and delete this
wrapper.
2015-12-17 16:57:25 +01:00
Cédric Bosdonnat
bec787ee9d Allow building lxc without virt-login-shell
Add a configure option to disable virt-login-shell build even if lxc is
enabled.
2015-12-17 15:49:06 +01:00
John Ferlan
8c865052b9 storage: Fix startup issue for logical pool
Commit id '71b803ac' assumed that the storage pool source device path
was required for a 'logical' pool. This resulted in a failure to start
a pool without any device path defined.

So, adjust the virStorageBackendLogicalMatchPoolSource logic to
return success if at least the pool name matches the vgs output
when no pool source device path is/are provided.
2015-12-17 08:20:22 -05:00
John Ferlan
5efcfb9695 qemu: Fix event generated for qemuDomainRevertToSnapshot (pause->run)
A closer review of the code shows that for the transition from paused to
running which was supposed to emit the VIR_DOMAIN_EVENT_RESUMED - no event
would be generated. Rather the event is generated when going from running
to running.

Following the 'was_running' boolean shows it is set when the domain obj
is active and the domain obj state is VIR_DOMAIN_RUNNING. So rather than
using was_running to generate the RESUMED event, use !was_running
2015-12-17 08:04:02 -05:00
John Ferlan
80ca86e54d storage: Attempt to refresh volume after successful wipe volume
https://bugzilla.redhat.com/show_bug.cgi?id=1270709

When a volume wipe is successful, perform a volume refresh afterwards to
update any volume data that may be used in future volume commands, such as
volume resize.  For a raw file volume, a wipe could truncate the file and
a followup volume resize the capacity may fail because the volume target
allocation isn't updated to reflect the wipe activity.
2015-12-17 07:30:03 -05:00
Ján Tomko
f61770a169 virStorageBackendWipeLocal: remove bytes_wiped argument
It is not used by the caller.
2015-12-17 12:44:35 +01:00
Ján Tomko
c3f7371c5e storage: drop 'Extent' from virStorageBackendWipeExtentLocal
The only caller always passes 0 for the extent start.
Drop the 'extent_start' parameter, as well as the mention of extents
from the function name.

Change off_t extent_length to unsigned long long wipe_len, as well as the
'remain' variable.
2015-12-17 12:44:35 +01:00
Ján Tomko
4bccdf0ceb storage: move buffer allocation inside virStorageBackendWipeExtentLocal
We do not need to pass a zero-filled buffer as an argument,
the function can allocate its own.
2015-12-17 12:44:35 +01:00
Ján Tomko
09cbfc0481 storage: fix return values of virStorageBackendWipeExtentLocal
Return -1:
* on all failures of fdatasync. Instead of propagating -errno
  all the way up to the virStorageVolWipe API, which is documented
  to return 0 or -1.
* after a partial wipe. If safewrite failed, we would re-use the
  non-negative return value of lseek (which should be 0 in this case,
  because that's the only offset we seek to).
2015-12-17 12:44:02 +01:00
Andrea Bolognani
242e3ea4e3 qemu: Replace Mlock with MemLock in function names
MemLock is already used in other modules and, while still an
abbreviation, is not ambiguous.
2015-12-17 10:12:47 +01:00
Andrea Bolognani
afbe1d4c56 qemu: Allow qemuDomainAdjustMaxMemLock() to restore previous value
When the function changes the memory lock limit for the first time,
it will retrieve the current value and store it inside the
virDomainObj for the domain.

When the function is called again, if memory locking is no longer
needed, it will be able to restore the memory locking limit to its
original value.
2015-12-17 10:12:47 +01:00
Andrea Bolognani
b583e80cb8 qemu: Reduce memlock limit after detaching PCI hostdev
We increase the limit before plugging in a PCI hostdev or a memory
module because some memory might need to be locked due to eg. VFIO.

Of course we should do the opposite after unplugging a device: this
was already the case for memory modules, but not for PCI hostdevs.
2015-12-17 10:12:47 +01:00
Andrea Bolognani
65909c7996 qemu: Use qemuDomainAdjustMaxMemLock()
Replace all uses of the qemuDomainRequiresMlock/virProcessSetMaxMemLock
combination with the equivalent qemuDomainAdjustMaxMemLock() call.
2015-12-17 10:12:47 +01:00
Andrea Bolognani
ac7e4df4f4 qemu: Add qemuDomainAdjustMaxMemLock()
This function detects whether a domain needs RLIMIT_MEMLOCK
to be set, and if so, uses an appropriate value.
2015-12-17 10:12:47 +01:00
Andrea Bolognani
bbefc9cc2e process: Add virProcessGetMaxMemLock()
This function can be used to retrieve the current locked memory
limit for a process, so that the setting can be later restored.

Add a configure check for getrlimit(), which we now use.
2015-12-17 10:12:47 +01:00
Andrea Bolognani
c2f797544f process: Allow virProcessPrLimit() to get current limit
The prlimit() function allows both getting and setting limits for
a process; expose the same functionality in our wrapper.

Add the const modifier for new_limit, in accordance with the
prototype for prlimit().
2015-12-17 10:12:47 +01:00
Eric Blake
df2fadfc6e build: disable vbox on cygwin
Cygwin cannot build the vbox driver yet:

  CC       vbox/libvirt_driver_vbox_impl_la-vbox_glue.lo
In file included from vbox/vbox_glue.c:27:0:
vblox/vbox_XPCOMCGlue.c:63:3: error: #error "Port me"
 # error "Port me"
   ^
In file included from vbox/vbox_XPCOMCGlue.c:45:0,
                 from vbox/vbox_glue.c:27:
vbox/vbox_XPCOMCGlue.c: In function 'tryLoadOne':
vbox/vbox_XPCOMCGlue.c:98:46: error: 'DYNLIB_NAME' undeclared (first use in this function)
         if (virAsprintf(&name, "%s/%s", dir, DYNLIB_NAME) < 0)
	                                      ^
./util/virstring.h:245:31: note: in definition of macro 'virAsprintf'
                         strp, __VA_ARGS__)
			       ^

Rather than trying to figure out how to get dynamic loading of
vbox to work under cygwin (since I don't even have a working vbox
setup to test whether it works), I'm going to be lazy and just
default to not even trying vbox on cygwin.
2015-12-16 16:32:31 -07:00
Martin Kletzander
68d4245d21 qemu: Search all nodes for shared memory access
In commit 686eb7a24f, the break was not considered part of the
condition, hence breaking after first node when searching.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-12-16 13:02:33 +01:00
Andrea Bolognani
7743454165 pci: Use virPCIDeviceAddress in virPCIDevice
Instead of replicating the information (domain, bus, slot, function)
inside the virPCIDevice structure, use the already-existing
virPCIDeviceAddress structure.

For users of the module, this means that the object returned by
virPCIDeviceGetAddress() can no longer be NULL and must no longer
be freed by the caller.
2015-12-16 09:07:25 +01:00
Ian Campbell
716be2570a libxl: Use libxentoollog in preference to libxenctrl if available.
Upstream Xen is in the process of splitting the (stable API) xtl_*
interfaces out from the (unstable API) libxenctrl library and into a
new (stable API) libxentoollog.

In order to be compatible with Xen both before and after this
transition check for xtl_createlogger_stdiostream in a libxentoollog
library and use it if present. If it is not present assume it is in
libxenctrl.

Compile tested on Xen 4.6 and a development tree with the split in
place.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2015-12-15 15:46:11 -07:00
Joao Martins
b7b439196c libxl: implement virDomainGetJobStats
Introduces support for domainGetJobStats which has the same
info as domainGetJobInfo but in a slightly different format.
Another difference is that virDomainGetJobStats can also
retrieve info on the most recently completed job. Though so
far this is only used in the source node to know if the
migration has been completed. But because we don't support
completed jobs we will deliver an error.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
2015-12-15 15:21:38 -07:00