Commit Graph

486 Commits

Author SHA1 Message Date
Pavel Hrdina
6bd0cd3b73 graphics: rename gListen to glisten
We have both in the code.  Let's use only one format.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-05-20 10:05:56 +02:00
Pavel Hrdina
b33c14b342 graphics: make address attribute for listen type='address' optional
We support omitting listen attribute of graphics element so we should
also support omitting address attribute of listen element.  This patch
also updates libvirt to always add a listen element into domain XML
except for VNC graphics if socket attribute is specified.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-05-17 10:41:45 +02:00
Cole Robinson
b1fc6a7b73 conf: domain: reject name containing '/'
Trying to define a domain name containing an embedded '/'
will immediately fail when trying to write the XML to disk for
our stateful drivers. This patch explicitly rejects names
containing a '/', and provides an xmlopt feature for drivers
to avoid this validation check, which is enabled in every
non-stateful driver that already has xmlopt handling wired up.

(Technically this could reject a previously accepted vmname like
 '/foo', however at least for the qemu driver that falls over
 later when starting qemu)

https://bugzilla.redhat.com/show_bug.cgi?id=639923
2016-05-02 10:06:04 -04:00
John Ferlan
27726d8c21 qemu: Introduce qemuDomainHostdevPrivatePtr
Modeled after the qemuDomainDiskPrivatePtr logic, create a privateData
pointer in the _virDomainHostdevDef to allow storage of private data
for a hypervisor in order to at least temporarily store auth/secrets
data for usage during qemuBuildCommandLine.

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

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

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-05-02 06:10:19 -04:00
Cole Robinson
18644491de vbox: VIR_WARN if we don't support the API version
We presently don't give any indication if the VirtualBox version
isn't in our support whitelist.
2016-04-23 13:40:56 -04:00
Pavel Hrdina
6e76738e54 build: fix build on RHEL-6
GCC in RHEL-6 complains about listen:

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

This renames all the listen to gListen.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-04-13 17:28:50 +02:00
Pavel Hrdina
f53bb3eda9 use virDomainGraphicsGetListen instead of the other getters
There is no point the use two different getters on the same listen
structure few lines apart.

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

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-04-13 10:43:49 +02:00
Peter Krempa
185d13b1b0 conf: refactor checking for unsupported memory devices
Introduce a helper to check supported device and domain config and move
the memory hotplug checks to it.

The advantage of this approach is that by default all new features are
considered unsupported by all hypervisors unless specifically changed
rather than the previous approach where every hypervisor would need to
declare that a given feature is unsupported.
2016-03-09 10:09:16 +01:00
Michal Privoznik
18f231e6ff _virtualboxCreateMachine: Avoid unbounded stack
If the stars are in the right position and you're building with
VBox >= 4.2.0 it will happen that compiler thinks an array
allocated on the stack may be unbounded:

In file included from vbox/vbox_V4_2.c:13:0:
vbox/vbox_tmpl.c: In function '_virtualboxCreateMachine':
vbox/vbox_tmpl.c:2811:1: error: stack usage might be unbounded [-Werror=stack-usage=]
 _virtualboxCreateMachine(vboxGlobalData *data, virDomainDefPtr def, IMachine **machine, char *uuidstr ATTRIBUTE_UNUSED)
 ^

Well, given how the variable is declared, I had some hard time
seeing it is actually bounded. Surprisingly compiler does not
complain because of -Wframe-larger-than. This is because
variable length arrays do not count into that warning.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-08 09:53:24 +01:00
Michal Privoznik
bde6e002b5 Initialize couple of variables.
While trying to build with -Os couple of compile errors showed
up.

conf/domain_conf.c: In function 'virDomainChrRemove':
conf/domain_conf.c:13666:24: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     virDomainChrDefPtr ret, **arrPtr = NULL;
                        ^
Compiler fails to see that @ret is used only if set in the loop,
but whatever, there's no harm in initializing the variable.

In vboxAttachDrivesNew and _vboxAttachDrivesOld compiler thinks
that @rc may be used uninitialized. Well, not directly, but maybe
after some optimization. Yet again, no harm in initializing a
variable.

In file included from ./util/virthread.h:26:0,
                 from ./datatypes.h:28,
                 from vbox/vbox_tmpl.c:43,
                 from vbox/vbox_V3_1.c:37:
vbox/vbox_tmpl.c: In function '_vboxAttachDrivesOld':
./util/virerror.h:181:5: error: 'rc' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     virReportErrorHelper(VIR_FROM_THIS, code, __FILE__,              \
     ^
In file included from vbox/vbox_V3_1.c:37:0:
vbox/vbox_tmpl.c:1041:14: note: 'rc' was declared here
     nsresult rc;
              ^
Yet again, one uninitialized variable:

qemu/qemu_driver.c: In function 'qemuDomainBlockCommit':
qemu/qemu_driver.c:17194:9: error: 'baseSource' may be used uninitialized in this function [-Werror=maybe-uninitialized]
         qemuDomainPrepareDiskChainElement(driver, vm, baseSource,
         ^

And another one:

storage/storage_backend_logical.c: In function 'virStorageBackendLogicalMatchPoolSource.isra.2':
storage/storage_backend_logical.c:618:33: error: 'thisSource' may be used uninitialized in this function [-Werror=maybe-uninitialized]
                       thisSource->devices[j].path))
                                 ^

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-03 14:39:57 +01:00
Michal Privoznik
a0e5faaf66 vbox: Avoid signed and unsigned comparison
After 457ff97fa there are two defects in our code. In both of
them we use a signed variable to hold up a number of snapshots
that domain has. We use a helper function to count the number.
However, the helper function may fail in which case it returns
a negative one and control jumps to cleanup label where an
unsigned variable is used to iterate over array of snapshots. The
loop condition thus compare signed and unsigned variables which
in this specific case ends up badly for us.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-02-23 15:38:20 +01:00
Martin Kletzander
457ff97fa2 Miscellaneous for-loop syntax clean-ups
Checking whether x > 0 before looping over [0..x] items doesn't make
sense and multi-line body must have curly brackets around it.

Best viewed with '-w'.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-02-22 11:29:59 +01:00
Ján Tomko
4d569245f0 vbox: remove more extra spaces 2016-02-11 07:32:50 +01:00
Ján Tomko
a3dd574a07 vbox: remove extra spaces from function headers
Also fix the curly brace to pass sytnax-check.
2016-02-11 07:32:50 +01:00
Ján Tomko
b31e4d00ec vbox: remove extra spaces from assignments 2016-02-11 07:32:50 +01:00
Ján Tomko
ebe24c84d4 vbox: remove extra spaces from variable initializations 2016-02-11 07:32:50 +01:00
Ján Tomko
628599935b vbox: remove extra spaces from macro definitions 2016-02-11 07:32:50 +01:00
Ján Tomko
6951ab6881 vboxDumpDisplay: realign variable initializations
Remove the extra spaces, do not align them on '='.
2016-02-09 10:11:56 +01:00
Ján Tomko
c5972df7d5 vboxDumpDisplay: remove suspicious strlen
The return type of strlen is 'size_t', which is unsigned and therefore
never less than zero.

Use STREQ to make the check obvious.
2016-02-09 10:11:05 +01:00
Ján Tomko
5a16197459 vboxDumpDisplay: reuse the keyUtf16 variable
We free the key right after calling the API.

Reuse a single variable to remove the typo.
2016-02-09 10:11:02 +01:00
Ján Tomko
2ab95531ca vboxDumpDisplay: use VIR_APPEND_ELEMENT
Instead of open-coding it.
2016-02-09 10:10:25 +01:00
Ján Tomko
ec74a9da7a vboxDumpDisplay: check return of virDomainGraphicsListenSetAddress
Error out if the allocation failed.
2016-02-09 10:10:24 +01:00
Ján Tomko
fcecbb37bf vboxDumpDisplay: clean up VIR_STRDUP usage
Two VIR_STRDUP calls are redundant - just steal the string
converted by VBOX_UTF16_TO_UTF8.

Report an error when the third one fails.
2016-02-09 10:09:41 +01:00
Ján Tomko
8f8c473a98 vboxDumpDisplay: fill out the graphics structure earlier
Remove the need to track what type of graphics were present
by temporary variables.
2016-02-09 10:09:23 +01:00
Ján Tomko
026bcfdcad vboxDumpDisplay: allocate the graphics structure upfront
Allocate it as soon as we know we will need it.

Add it to def->ngraphics if it's allocated, removing the need
to use the addDesktop and totalPresent variables to track this.
2016-02-09 10:09:19 +01:00
Ján Tomko
ef98d93bed vboxDumpDisplay: split out def->graphics allocation
Separate allocation of the def->graphics array from the allocation
and initialization of its first element.

Note that the only possible values of totalPresent at this point
are 0 or 1, because it equals to guiPresent + sdlPresent.
2016-02-09 10:08:39 +01:00
Ján Tomko
2f2a0b2925 vboxDumpDisplay: remove extra virReportOOMError
VIR_ALLOC* already reported an error.
2016-02-09 10:08:11 +01:00
Ján Tomko
56886d5fdd vboxDumpDisplay: add addDesktop bool
When FRONTEND/Type is not any of "sdl", "gui", "vrdp", we add a DESKTOP.
Use a bool to track this, instead of checking that both
totalPresent ("sdl" or "gui" present) and vrdpPresent are zero.
2016-02-09 10:08:00 +01:00
Ján Tomko
bf1691e388 vboxDumpDisplay: more indentation reducing
VRDxEnabled is initialized to false. Put the if (VRDxEnabled)
on the top level to reduce nesting.
2016-02-09 10:07:57 +01:00
Ján Tomko
5cb926f90d vboxDumpDisplay: reduce indentation level
Use STREQ_NULLABLE instead of deep nesting.
2016-02-09 10:07:37 +01:00
Ján Tomko
2ea694053f Check return value of vboxDumpVideo
Error out on allocation failures instead of creating an incomplete
definition.

Fixes a possible crash when def->nvideos is 1, but def->videos is NULL.
2016-02-09 10:06:58 +01:00
Joao Martins
b8b03f64e1 conf: add caps to virDomainSnapshotDefFormat
The virDomainSnapshotDefFormat calls into virDomainDefFormat,
so should be providing a non-NULL virCapsPtr instance. On the
qemu driver we change qemuDomainSnapshotWriteMetadata to also
include caps since it calls virDomainSnapshotDefFormat.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
2016-02-05 10:57:39 +00:00
Joao Martins
d239a5427f conf: add caps to virDomainDefFormat*
And use the newly added caps->host.netprefix (if it exists) for
interface names that match the autogenerated target names.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
2016-02-04 12:38:26 +00:00
Martin Kletzander
93103da84b Provide parse flags to PostParse functions
This way both Domain and Device PostParse functions can act based on the
flags.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-01-11 10:54:50 +01:00
Peter Krempa
957d597330 conf: Replace writes to def->vcpus with accessor 2015-12-09 14:57:12 +01:00
Peter Krempa
d1dda68777 conf: Replace read access to def->maxvcpus with accessor
Finalize the refactor by adding the 'virDomainDefGetVCpusMax' getter and
reusing it accross libvirt.
2015-12-09 14:57:12 +01:00
Peter Krempa
c970c4a5ea conf: Add helper to check whether domain has offline vCPUs
The new helper will simplify checking whether the domain config contains
inactive vCPUs.
2015-12-09 14:57:12 +01:00
Peter Krempa
4e187169f0 conf: Replace writes to def->maxvcpus with accessor
To support further refactors replace all write access to def->maxvcpus
with a accessor function.
2015-12-09 14:57:12 +01:00
Michal Privoznik
90f3c0d717 conf: Split virDomainObjList into a separate file
Our domain_conf.* files are big enough. Not only they contain XML
parsing code, but they served as a storage of all functions whose
name is virDomain prefixed. This is just wrong as it gathers not
related functions (and modules) into one big file which is then
harder to maintain. Split virDomainObjList module into a separate
file called virdomainobjlist.[ch].

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-11-30 13:55:10 +01:00
Marc-André Lureau
806ae49933 domain: replace bool accel{2d, 3d} with a tristate
Allowing to have the extra undefined/default state.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-11-27 16:48:53 +01:00
Marc-André Lureau
56a4fe2818 Replace support{2d,3d} with accel{2d,3d}
Following the domain XML naming

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
2015-11-27 16:48:53 +01:00
Peter Krempa
8059a99025 conf: Rename max_balloon to total_memory
The name of the variable was misleading. Rename it and it's setting
accessor before other fixes.
2015-09-22 16:09:28 +02:00
John Ferlan
b97b30480d nodeinfo: Add sysfs_prefix to nodeCapsInitNUMA
Add the sysfs_prefix argument to the call to allow for setting the
path for tests to something other than SYSFS_CPU_PATH which is a
derivative of SYSFS_SYSTEM_PATH

Use cpupath for nodeCapsInitNUMAFake and remove SYSFS_CPU_PATH
2015-07-13 15:59:32 -04:00
John Ferlan
29e4f2243f nodeinfo: Add sysfs_prefix to nodeGetInfo
Add the sysfs_prefix argument to the call to allow for setting the
path for tests to something other than SYSFS_SYSTEM_PATH.
2015-07-13 15:59:32 -04:00
Ján Tomko
12b949dfb2 maint: remove incorrect apostrophes from 'its' 2015-06-04 10:01:42 +02:00
Jiri Denemark
890fa6a055 Add privateData to virDomainDiskDef
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-05-15 08:04:26 +02:00
John Ferlan
74aab575c4 vbox: Resolve Coverity RESOURCE_LEAK
If the virStringSearch() returns a 0 (zero), then each of the uses
of the call will just jump to cleanup forgetting to free the returned
empty list. Expand the scope a bit of each use and free at cleanup.
2015-05-05 20:02:36 -04:00
Cole Robinson
835cf84b7e domain: conf: Drop expectedVirtTypes
This needs to specified in way too many places for a simple validation
check. The ostype/arch/virttype validation checks later in
DomainDefParseXML should catch most of the cases that this was covering.
2015-04-20 16:43:43 -04:00
Cole Robinson
4fa6f9b413 caps: Convert to use VIR_DOMAIN_VIRT internally 2015-04-20 16:40:26 -04:00