Having a daemon/ directory makes little sense from a code structure
point of view, as 90% of the code that is built into libvirtd already
lives in the src/ directory. The virtlockd and virlogd daemons also live
entirely in src/{locking,logging} directories. This moves the source
code for libvirtd into src/remote/, alongside the client code.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
The THREADS.txt describes the way threading worked in libvirtd many many
years ago, long before even the RPC code was modularized. Things have
evolved significantly since then, so delete this potentially misleading doc.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Remove lots of duplication in the sysconfig file handling, so we can
add more conf files without modifying so many places.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Remove lots of duplication in the sysv init file handling, so we can
add more init files without modifying so many places.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Remove lots of duplication in the systemd unit file handling, so we can
add more unit files without modifying so many places.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Address warning from -Wswitch-enum by adding missing cases
for graphics listen types that are not supported.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
libxl supports setting the domain real time clock to local time or
UTC via the localtime field of libxl_domain_build_info. Adjustment
of the clock is also supported via the rtc_timeoffset field. The
libvirt libxl driver has never supported these settings, instead
relying on libxl's default of a UTC real time clock with adjustment
set to 0.
There is at least one user that would like the ability to change
the defaults
https://www.redhat.com/archives/libvirt-users/2018-February/msg00059.html
Add support for specifying a local time clock and for specifying an
adjustment for both local time and UTC clocks. Add a test case to
verify the XML to libxl_domain_config conversion.
Local time clock and clock adjustment is already supported by the
XML <-> xl.cfg converter. What is missing is an explicit test for
the conversion. There are plenty of existing tests that all use UTC
with 0 adjustment. Hijack test-fullvirt-tsc-timer to test a local
time clock with 1 hour adjustment.
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
As a general rule any time we switch() on something that is an enum, we
want to have a case for every enum constant. The -Wswitch warning will
report any switch where we've violated this rule, except if that switch
has a default case.
Unfortunately it is reasonable to want to list all enum constants *and*
also have a default case. To get a warning in that scenario requires
that we turn on -Wswitch-enum.
In a few cases where we explicitly don't want to list all enum cases, we
can discard the enum type checking by casting the value to a plain int.
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Cast away enum type in places where we don't wish to cover all cases.
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Ensure all enum cases are listed in switch statements.
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Ensure all enum cases are listed in switch statements.
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Ensure all enum cases are listed in switch statements.
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Ensure all enum cases are listed in switch statements, or cast away
enum type in places where we don't wish to cover all cases.
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Ensure all enum cases are listed in switch statements, or cast away
enum type in places where we don't wish to cover all cases.
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Ensure all enum cases are listed in switch statements, or cast away
enum type in places where we don't wish to cover all cases.
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Cast away enum type for libxl scheduler constants since we don't want to
cover all of them and don't want build to break when new ones are added.
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Ensure all enum cases are listed in switch statements. This improves
debug logging integration with openwsman.
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Ensure all enum cases are listed in switch statements, or explicitly
cast away enum type where we don't want to list all cases.
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Ensure all enum cases are listed in switch statements.
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Ensure all enum cases are listed in switch statements.
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
To ensure we have standardized error messages when reporting problems
with enum values being out of a range, add virReportEnumRangeError().
virReportEnumRangeError(virDomainState, 34);
results in a message
"internal error: Unexpected enum value 34 for virDomainState"
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Currently building --without-libvirtd causes a failure to link the node
device driver:
node_device/.libs/libvirt_driver_nodedev_la-node_device_driver.o: In function `nodedevRegister':
/home/berrange/src/virt/libvirt/src/node_device/node_device_driver.c:649: undefined reference to `udevNodeRegister'
collect2: error: ld returned 1 exit status
because it causes us to build the core nodedev driver, but then skip the
implementations, despite udev being available.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
These two objects are used to access fields in actual ethernet packets
captures with libpcap, so it's essential that they don't change size
for any reason. This patch uses gnulib's verify() macro to make sure
their sizes don't change.
Signed-off-by: Laine Stump <laine@laine.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
GCC 8 became more fussy about detecting switch
fallthroughs. First it doesn't like it if you have
a fallthrough attribute that is not before a case
statement. e.g.
FOO:
BAR:
WIZZ:
ATTRIBUTE_FALLTHROUGH;
Is unacceptable as there's no final case statement,
so while FOO & BAR are falling through, WIZZ is
not falling through. IOW, GCC wants us to write
FOO:
BAR:
ATTRIBUTE_FALLTHROUGH;
WIZZ:
Second, it will report risk of fallthrough even if you
have a case statement for every single enum value, but
only if the switch is nested inside another switch and
the outer case statement has no final break. This is
is arguably valid because despite the fact that we have
cast from "int" to the enum typedef, nothing guarantees
that the variable we're switching on only contains values
that have corresponding switch labels. e.g.
int domstate = 87539319;
switch ((virDomainState)domstate) {
...
}
will not match enum value, but also not raise any kind
of compiler warning. So it is right to complain about
risk of fallthrough if no default: is present.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
The controller model is slightly unusual in that the default value is
-1, not 0. As a result the default value is not covered by any of the
existing enum cases. This in turn means that any switch() statements
that think they have covered all cases, will in fact not match the
default value at all. In the qemuDomainDeviceCalculatePCIConnectFlags()
method this has caused a serious mistake where we fallthrough from the
SCSI controller case, to the VirtioSerial controller case, and from
the USB controller case to the IDE controller case.
By adding explicit enum constant starting at -1, we can ensure switches
remember to handle the default case.
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
There's no need to perform checks before conversion, we can just
call virDomainControllerPCIModelNameTypeToString() and check the
results later on.
Since the variables involved are only used for PCI controllers,
we can declare them in the 'case' scope rather than in the
function scope to make everything a bit nicer while at it.
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Performing the skip earlier will help us making the function
nicer later on. We also make the condition for the skip a bit
more precise, though that'a more for self-documenting purposes
and doesn't change anything in practice.
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
This function returns nothing but zero. Therefore it makes no
sense to have it returning an integer.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
If formatting of storage encryption or private data fails we must
jump to the error label instead of returning immediately
otherwise @attrBuf and @childBuf might be leaked.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
The src/Makefile.am rules all re-generate the RPC dispatch code whenever
the Makefile.am changes, so for consistency do that for
daemon/Makefile.am too.
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
When you add a bunch of pcie-root-port controllers to a q35 guest
in order to have hotplug capabilities, you also need to make sure
you're adding the pcie-root controller at the same time or you
will get an error. Document this fact.
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This file was modified in an editor buffer but not saved prior to
commit e62cb4a9b7 (which removed virMacAddr::generated), so the bhyve
build would fail.
Signed-off-by: Laine Stump <laine@laine.org>
Commit 7e62c4cd26 (first appearing in libvirt-3.9.0 as a resolution
to rhbz #1343919) added a "generated" attribute to virMacAddr that was
set whenever a mac address was auto-generated by libvirt. This
knowledge was used in a single place - when trying to match a NetDef
from the Domain to Delete with user-provided XML. Since the XML parser
always auto-generates a MAC address for NetDefs when none is provided,
it was previously impossible to make a search where the MAC address
isn't significant, but the addition of the "generated" attribute made
it possible for the search function to ignore auto-generated MACs.
This implementation had a problem though - it was adding a field to a
"low level" struct - virMacAddr - which is used in other places with
the assumption that it contains exactly a 6 byte MAC address and
nothing else. In particular, virNWFilterSnoopEthHdr uses virMacAddr as
part of the definition of an ethernet packet header, whose layout must
of course match an actual ethernet packet. Adding the extra bools into
virNWFilterSnoopEthHdr caused the nwfilter driver's "IP discovery via
DHCP packet snooping" functionality to mysteriously stop working.
In order to fix that behavior, and prevent potential future similar
odd behavior, this patch moves the "generated" member out of
virMacAddr (so that it is again really is just a MAC address) into
virDomainNetDef, and sets it only when virDomainNetGenerateMAC() is
called from virDomainNetDefParseXML() (which is the only time we care
about it).
Resolves: https://bugzilla.redhat.com/1529338
(It should also be applied to any maintenance branch that applies
commit 7e62c4cd26 and friends to resolve
https://bugzilla.redhat.com/1343919)
Signed-off-by: Laine Stump <laine@laine.org>
It is very difficult while reading the migration code trying to
understand whether a particular function is being called on the src side
or the dst side, or either. Putting "Src" or "Dst" in the method names will
make this much more obvious. "Any" is used in a few helpers which can be
called from both sides.
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
QEMU code does not work well with too big numbers on the JSON monitor so
our monitor code supports sending only numbers up to LLONG_MAX. Avoid a
weird error message by limiting the size of the 'bandwidth' parameter
for block copy.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1532542
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
The variable names for the options and information about a command
should have an underscore in places where the virsh command has a
hyphen. The function callback name should capitalize the letter after
the hyphen. This was not used in 'blockcommit', 'blockcopy', 'blockjob',
'blockpull', and 'blockresize' commands.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Commit 2d43f0a2dc dropped virDomainDiskTranslateSourcePool()'s
first argument but failed to update callers in the bhyve driver.
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Further cleanup from
commit 0c63c117a2
Author: Daniel P. Berrangé <berrange@redhat.com>
Date: Fri Feb 9 15:08:53 2018 +0000
conf: reimplement virDomainNetResolveActualType in terms of public API
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
The qemuxml2argvtest does not need to link to the network driver
after this commit:
commit 0c63c117a2
Author: Daniel P. Berrangé <berrange@redhat.com>
Date: Fri Feb 9 15:08:53 2018 +0000
conf: reimplement virDomainNetResolveActualType in terms of public API
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
These APIs are not required anywhere outside the migration code so need
not be exported to the rest of the QEMU driver.
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
The qemuMigrationPrecreateStorage method needs a connection
to access the storage driver. Instead of passing it around,
open it at time of use.
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
There's a few places in startup code paths which pass around a
virConnectPtr which is no longer required. Specifically, the
qemuProcessStart() method now only requires a non-NULL connection if
autodestroy is requested.
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
When setting up graphics, we sometimes need to resolve networks,
requiring the caller to pass in a virConnectPtr, except sometimes they
pass in NULL. Use virGetConnectNetwork() to acquire the connection to
the network driver when it is needed.
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
During domain startup there are many places where we need to acquire
secrets. Currently code passes around a virConnectPtr, except in the
places where we pass in NULL. So there are a few codepaths where ability
to start guests using secrets will fail. Change to acquire a handle to
the secret driver when needed.
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Rather than expecting callers to pass a virConnectPtr into the
virDomainDiskTranslateSourcePool() method, just acquire a connection
to the storage driver when needed.
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>