Commit Graph

17935 Commits

Author SHA1 Message Date
Peter Krempa
006a532cc0 qemu: driver: Don't return automatic NUMA emulator pinning data for persistentDef
Calling virDomainGetEmulatorPinInfo on a live VM with automatic NUMA
pinning and VIR_DOMAIN_AFFECT_CONFIG would return the automatic pinning
data in some cases which is bogus. Use the autoCpuset property only when
called on a live definition.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1365779
2016-09-21 16:32:36 +02:00
Peter Krempa
552892c59d qemu: driver: Don't return automatic NUMA vCPU pinning data for persistentDef
Calling virDomainGetVcpuPinInfo on a live VM with automatic NUMA pinning
and VIR_DOMAIN_AFFECT_CONFIG would return the automatic pinning data
in some cases which is bogus. Use the autoCpuset property only when
called on a live definition.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1365779
2016-09-21 16:32:36 +02:00
Peter Krempa
63aac8c299 qemu: domain: Add macro to simplify access to vm private data
Sometimes adding a separate variable to access vm->privateData is not
necessary. Add a macro that will do the typecasting rather than having
to add a temp variable to force the compiler to typecast it.
2016-09-21 16:32:36 +02:00
Peter Krempa
4cc65b4967 conf: Introduce virDomainObjGetOneDefState
Return whether the live or persistent definition was returned. Sometimes
it's necessary to base the decisions on this.
2016-09-21 16:32:36 +02:00
Jiri Denemark
2e164b451e qemu: Ignore graphics cookie if port == 0
Old libvirt represents

    <graphics type='spice'>
      <listen type='none'/>
    </graphics>

as

    <graphics type='spice' autoport='no'/>

In this mode, QEMU doesn't listen for SPICE connection anywhere and
clients have to use virDomainOpenGraphics* APIs to attach to the domain.
That is, the client has to run on the same host where the domains runs
and it's impossible to tell the client to reconnect to the destination
QEMU during migration (unless there is some kind of proxy on the host).

While current libvirt correctly ignores such graphics devices when
creating graphics migration cookie, old libvirt just sends

    <graphics type='spice' port='0' listen='0.0.0.0' tlsPort='-1'/>

in the cookie. After seeing this cookie, we happily would call
client_migrate_info QMP command and wait for SPICE_MIGRATE_COMPLETED
event, which is quite pointless since the doesn't know where to connecti
anyway. We should just ignore such cookies.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-09-21 14:11:26 +02:00
Jiri Denemark
53ae58b0ed qemuDomainOpenGraphics: Start job early
Checking if a domain's definition or if it is active before we got a job
is pointless since the domain might have changed in the meantime.

Luckily libvirtd didn't crash when the API tried to talk to an inactive
domain:

debug : qemuDomainObjBeginJobInternal:2914 : Started job: modify
    (async=none vm=0x7f8f340140c0 name=ble)
debug : qemuDomainObjEnterMonitorInternal:3137 : Entering monitor
    (mon=(nil) vm=0x7f8f340140c0 name=ble)
warning : virObjectLock:319 : Object (nil) ((unknown)) is not a
    virObjectLockable instance
debug : qemuMonitorOpenGraphics:3505 : protocol=spice fd=27
    fdname=graphicsfd skipauth=1
error : qemuMonitorOpenGraphics:3508 : invalid argument: monitor must
    not be NULL
debug : qemuDomainObjExitMonitorInternal:3160 : Exited monitor
    (mon=(nil) vm=0x7f8f340140c0 name=ble)
debug : qemuDomainObjEndJob:3068 : Stopping job: modify (async=none
    vm=0x7f8f340140c0 name=ble)

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-09-21 14:11:26 +02:00
Nikolay Shirokovskiy
6bff9c03c9 qemu: agent: give better error messages whe agent monitor is down
We can receive NULL as sync reply in two situations. First
is garbage sync reply and this situation is handled by
resending sync message. Second is different cases
of rebooting guest, destroing domain etc and we can
give more meaningful error message. Actually we have
this error message in qemuAgentCommand already which checks
for the same sitatuion. AFAIK case with mon->running
is just to be safe on adding some future(?) cases of
returning NULL reply.
2016-09-20 16:27:58 +02:00
Nikolay Shirokovskiy
3f90a1aac0 qemu: agent: reissue sync on garbage sync reply
We can easily handle receiving garbage on sync. We don't
have to make client deal with this situation. We just
need to resend sync command but this time garbage is
not be possible.
2016-09-20 16:27:58 +02:00
Nikolay Shirokovskiy
5e5019bf78 qemu: agent: skip outdated sync replies
When we wait for sync reply we can receive delayed
reply to syncs or commands that were sent erlier. We can
safely skip them until we receive sync reply with correct id.
There is no much sense report this situation to client.
Actually with a bit of "luck" if we involve client into
this the play can go on forever: send sync 0, receive
sync reply -1, send sync 1, receive reply 0 ...
2016-09-20 16:27:58 +02:00
Nikolay Shirokovskiy
832d48d790 qemu: agent: ignore garbage while waiting for sync reply
After sync is sent we can receive garbare and this is not error.
Consider next regular case:

1. libvirtd sends sync
2. qga sends partial sync reply and die
3. libvirtd sends sync
4. qga sends sync reply
5. libvirtd receives garbage
  (half of first reply and second reply together)

We should handle this situation as it is recoverable.
Next sync can succeed. Let's report reply is NULL,
it will be converted to the VIR_ERR_AGENT_UNSYNCED
which signals client to retry.
2016-09-20 16:27:58 +02:00
Nikolay Shirokovskiy
4fd25421e3 qemu: agent: ignore delayed reply when unsynced
Errors in qemuAgentIOProcessLine stop agent IO processing just
like any regular IO error, however some of current errors
that this functions spawns are false positives. Consider
next case for example:

1. send sync (unsynced state)
2. receive sync reply (sync established)
3. command send, but timeout occured (unsynced state)
4. receive command reply

Last IO triggers error because current code ignores
only delayed syncs when unsynced

We should not treat any delayed reply as error in unsynced
state. Until client and qga are not in sync delayed reply to any
command is possible. msg == NULL is the exact criterion
that we are not in sync.
2016-09-20 16:27:58 +02:00
Martin Kletzander
e5568193f4 conf: Add some shmem helpers for future use
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-09-20 15:42:43 +02:00
Martin Kletzander
a9996a4599 qemu: Add qemuAssignDeviceShmemAlias and use it
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-09-20 15:42:43 +02:00
Martin Kletzander
a0c99e1a0a qemu: Rename qemuBuildShmemBackendStr to qemuBuildShmemBackendChrStr
There will be more backends in the future so let's not complicate it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-09-20 15:42:43 +02:00
Martin Kletzander
0f61d7b5f2 qemu: Abstract shmem socket path preparation
Put it into qemuDomainPrepareShmemChardev() so it can be used later.
Also don't fill in the path unless the server option is enabled.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-09-20 15:42:43 +02:00
Martin Kletzander
6b5622e4b5 qemu: Reorder shmem params nicely
Always format id first so that we don't need to do that twice in
different code paths.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-09-20 15:42:43 +02:00
Martin Kletzander
9187cecc81 qemu: Move common checks outside qemuBuildShmemDevLegacyStr
Some checks will need to be performed for newer device types as well, so
let's not duplicate them.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-09-20 15:42:43 +02:00
Martin Kletzander
bf854ae3f1 qemu: Rename qemuBuildShmemDevStr to qemuBuildShmemDevLegacyStr
This will make sense after adding support for newer device types.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-09-20 15:42:43 +02:00
Martin Kletzander
c7e0a6a667 qemu: Make qemuBuildShmemDevStr static
It isn't used anywhere else.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-09-20 15:42:43 +02:00
Andrea Bolognani
f496ce1df3 virtlogd: Don't stop or restart along with libvirtd
Commit 839a060 tied the lifecycle of virtlogd more
closely to that of libvirtd. Unfortunately, while starting
virtlogd when libvirtd is started is definitely a good idea,
restarting virtlogd or shutting it down at any time outside
of system poweroff is not.

Revert part of that commit by removing the PartOf= lines,
meaning that only startup requests will be propagated from
libvirtd to virtlogd.

Resolves: https://bugzilla.redhat.com/1372576
2016-09-20 15:22:04 +02:00
Chen Hanxiao
fb360df4b0 qemu_process: fix a typo
s/unitl/until

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
2016-09-20 10:48:58 +02:00
Michal Privoznik
eef8b26372 qemu: Introduce qemuGetHupageMemPath
Now that we have two same implementations for getting path for
huge pages backed guest memory, lets merge them into one function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-09-19 13:45:05 +02:00
Michal Privoznik
647db05e9a qemuBuildMemoryBackendStr: Don't crash if no hugetlbfs is mounted
When trying to migrate a huge page enabled guest, I've noticed
the following crash. Apparently, if no specific hugepages are
requested:

  <memoryBacking>
    <hugepages/>
  </memoryBacking>

and there are no hugepages configured on the destination, we try
to dereference a NULL pointer.

Program received signal SIGSEGV, Segmentation fault.
0x00007fcc907fb20e in qemuGetHugepagePath (hugepage=0x0) at qemu/qemu_conf.c:1447
1447        if (virAsprintf(&ret, "%s/libvirt/qemu", hugepage->mnt_dir) < 0)
(gdb) bt
#0  0x00007fcc907fb20e in qemuGetHugepagePath (hugepage=0x0) at qemu/qemu_conf.c:1447
#1  0x00007fcc907fb2f5 in qemuGetDefaultHugepath (hugetlbfs=0x0, nhugetlbfs=0) at qemu/qemu_conf.c:1466
#2  0x00007fcc907b4afa in qemuBuildMemoryBackendStr (size=4194304, pagesize=0, guestNode=0, userNodeset=0x0, autoNodeset=0x0, def=0x7fcc70019070, qemuCaps=0x7fcc70004000, cfg=0x7fcc5c011800, backendType=0x7fcc95087228, backendProps=0x7fcc95087218,
    force=false) at qemu/qemu_command.c:3297
#3  0x00007fcc907b4f91 in qemuBuildMemoryCellBackendStr (def=0x7fcc70019070, qemuCaps=0x7fcc70004000, cfg=0x7fcc5c011800, cell=0, auto_nodeset=0x0, backendStr=0x7fcc70020360) at qemu/qemu_command.c:3413
#4  0x00007fcc907c0406 in qemuBuildNumaArgStr (cfg=0x7fcc5c011800, def=0x7fcc70019070, cmd=0x7fcc700040c0, qemuCaps=0x7fcc70004000, auto_nodeset=0x0) at qemu/qemu_command.c:7470
#5  0x00007fcc907c5fdf in qemuBuildCommandLine (driver=0x7fcc5c07b8a0, logManager=0x7fcc70003c00, def=0x7fcc70019070, monitor_chr=0x7fcc70004bb0, monitor_json=true, qemuCaps=0x7fcc70004000, migrateURI=0x7fcc700199c0 "defer", snapshot=0x0,
    vmop=VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_START, standalone=false, enableFips=false, nodeset=0x0, nnicindexes=0x7fcc95087498, nicindexes=0x7fcc950874a0, domainLibDir=0x7fcc700047c0 "/var/lib/libvirt/qemu/domain-1-fedora") at qemu/qemu_command.c:9547

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-09-19 13:44:48 +02:00
Chen Hanxiao
4c886408c0 qemu_agent|monitor: use different log on hangup event
Both qemu monitor and agent print the same
log on HUANGUP event, which would be confusing
when reading libvirtd log.

This patch will give a different log message to them.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2016-09-19 13:06:03 +02:00
Martin Kletzander
921ec15fdb conf: Allow copying of shmem defs
This way we'll be able to hotplug with both --live and --config in one
API call.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-09-16 15:38:14 +02:00
Laszlo Ersek
706b5b6277 qemu: map "virtio" video model to "virt" machtype correctly (arm/aarch64)
Most of QEMU's PCI display device models, such as:

  libvirt video/model/@type  QEMU -device
  -------------------------  ------------
  cirrus                     cirrus-vga
  vga                        VGA
  qxl                        qxl-vga
  virtio                     virtio-vga

come with a linear framebuffer (sometimes called "VGA compatibility
framebuffer"). This linear framebuffer lives in one of the PCI device's
MMIO BARs, and allows guest code (primarily: firmware drivers, and
non-accelerated OS drivers) to display graphics with direct memory access.

Due to architectural reasons on aarch64/KVM hosts, this kind of
framebuffer doesn't / can't work in

  qemu-system-(arm|aarch64) -M virt

machines. Cache coherency issues guarantee a corrupted / unusable display.
The problem has been researched by several people, including kvm-arm
maintainers, and it's been decided that the best way (practically the only
way) to have boot time graphics for such guests is to consolidate on
QEMU's "virtio-gpu-pci" device.

>From <https://bugzilla.redhat.com/show_bug.cgi?id=1195176>, libvirt
supports

  <devices>
    <video>
      <model type='virtio'/>
    </video>
  </devices>

but libvirt unconditionally maps @type='virtio' to QEMU's "virtio-vga"
device model. (See the qemuBuildDeviceVideoStr() function and the
"qemuDeviceVideo" enum impl.)

According to the above, this is not right for the "virt" machine type; the
qemu-system-(arm|aarch64) binaries don't even recognize the "virtio-vga"
device model (justifiedly). Whereas "virtio-gpu-pci", which is a pure
virtio device without a compatibility framebuffer, is available, and works
fine.

(The ArmVirtQemu ("AAVMF") platform of edk2 -- that is, the UEFI firmware
for "virt" -- supports "virtio-gpu-pci", as of upstream commit
3ef3209d3028. See
<https://tianocore.acgmultimedia.com/show_bug.cgi?id=66>.)

Override the default mapping of "virtio", from "virtio-vga" to
"virtio-gpu-pci", if qemuDomainMachineIsVirt() evaluates to true.

Cc: Andrea Bolognani <abologna@redhat.com>
Cc: Drew Jones <drjones@redhat.com>
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Cc: Martin Kletzander <mkletzan@redhat.com>
Suggested-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1372901
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Martin Kletzander <mkletzan@redhat.com>
2016-09-16 14:13:07 +02:00
Martin Kletzander
b51e26f755 util: Expose virHostCPUStatsAssign on non-Linux
There is nothing Linux-specific in that function.  Also since commit
8c3b5bf481 mingw build is broken due to
the fact that this function is not compiled in the library.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-09-16 08:33:47 +02:00
Tomáš Ryšavý
d18c7d7124 test driver: Implement testNodeGetFreePages.
Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
2016-09-15 15:28:22 +02:00
Tomáš Ryšavý
dc98750a06 test driver: added pages sizes into XML into test driver.
Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
2016-09-15 15:28:22 +02:00
Tomáš Ryšavý
13ae5da9e3 test driver: Implement testNodeGetFreeMemory
Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-09-15 15:28:22 +02:00
Tomáš Ryšavý
8c3b5bf481 test driver: Implement testNodeGetCPUStats
Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-09-15 15:28:22 +02:00
Tomáš Ryšavý
5cdc3b8227 test driver: Implement virConnectGetType.
Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-09-15 15:28:22 +02:00
Tomáš Ryšavý
5418719597 test driver: Implement virConnectGetSysinfo.
Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-09-15 15:28:22 +02:00
Tomáš Ryšavý
23d9d25e97 test_driver: Replace magic constant
In testOpenDefault we create a virtual computer that is later
presented to user. We also pretend to have NUMA cells and
initialize them somehow. But whilst doing so a magical constant
is used. Drop it.

Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-09-15 15:28:22 +02:00
Tomáš Ryšavý
63f388c99d virhostcpu: Expose virHostCPUStatsAssign
We will need this function shortly when implementing
nodeGetCPUStats in the test driver.

Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-09-15 15:28:22 +02:00
Jason Miesionczek
ead3cfc68d hyperv: additional server 2008 wmi classes 2016-09-15 09:27:48 +02:00
Peter Krempa
64bc75f756 qemu: domain: Don't infer vcpu state
Use the state information (online, hotpluggable) provided by the monitor
code rather than trying to infer it. This fixes an issue where on
architectures that require hotplug of multiple threads at once the
sub-cores would get updated as offline on daemon restart thus creating
an invalid configuration.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1375783
2016-09-14 12:56:57 +02:00
Peter Krempa
2a0e68be91 qemu: monitor: Add vcpu state information to monitor data
Return whether a vcpu entry is hotpluggable or online so that upper
layers don't have to infer the information from other data.

Advantage is that this code can be tested by unit tests.
2016-09-14 12:55:33 +02:00
Peter Krempa
66da0356cd qemu: monitor: qemuMonitorGetCPUInfoHotplug: Add iterator 'anycpu'
Add separate iterator for iterating all the entries
2016-09-14 12:55:33 +02:00
Peter Krempa
03376b6da0 qemu: monitor: Use a more obvious iterator name
The algorithm that matches data from query-cpus and
query-hotpluggable-cpus is quite complex. Start using descriptive
iterator names to avoid confusion.
2016-09-14 12:55:33 +02:00
Michal Privoznik
988218ca3f virDomainGetBlockJobInfo: Fix corner case when qemu reports no info
https://bugzilla.redhat.com/show_bug.cgi?id=1372613

Apparently, some management applications use the following code
pattern when waiting for a block job to finish:

  while (1) {
    virDomainGetBlockJobInfo(dom, disk, info, flags);

    if (info.cur == info.end)
        break;

    sleep(1);
  }

Problem with this approach is in its corner cases. In case of
QEMU, libvirt merely pass what has been reported on the monitor.
However, if the block job hasn't started yet, qemu reports cur ==
end == 0 which tricks mgmt apps into thinking job is complete.

The solution is to mangle cur/end values as described here [1].

1: https://www.redhat.com/archives/libvir-list/2016-September/msg00017.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-09-14 12:44:42 +02:00
Michal Privoznik
5d213b34de qemuDomainGetBlockJobInfo: Move info translation into separate func
Even though we merely just pass to users whatever qemu provided
on the monitor, we still do some translation. For instance we
turn bytes into mebibytes, or fix job type if needed. However, in
the future there is more fixing to be done so this code deserves
its own function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-09-14 12:44:42 +02:00
Peter Krempa
77cb01bc0f numa: Rename virNumaGetHostNodeset and make it return only nodes with memory
Name it virNumaGetHostMemoryNodeset and return only NUMA nodes which
have memory installed. This is necessary as the kernel is not very happy
to set the memory cgroup setting for nodes which do not have any memory.

This would break vcpu hotplug with following message on such
configruation:

  Invalid value '0,8' for 'cpuset.mems': Invalid argument

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1375268
2016-09-14 08:41:41 +02:00
Peter Krempa
5555dc0d7f util: numa: Remove impossible error handling
The code guarantees that virBitmapSetBit won't be called with out of
range values. Just ignore the return value and remove dead error
handling.
2016-09-14 08:41:41 +02:00
Peter Krempa
f428ff8ad4 qemu: Add missing 'p' to qemuCgrouEmulatorAllNodesRestore 2016-09-13 12:24:02 +02:00
Nikolay Shirokovskiy
048e5c64f7 qemu: add VIR_DOMAIN_UNDEFINE_KEEP_NVRAM support
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-09-13 09:31:50 +02:00
Laine Stump
b87703cf79 conf: allow hotplugging "legacy PCI" device to manually addressed PCIe slot
In a full domain config, libvirt allows overriding the normal PCI
vs. PCI Express rules when a device address is explicitly provided
(so, e.g., you can force a legacy PCI device to plug into a PCIe port,
although libvirt would never do that on its own). However, due to a
bug libvirt doesn't give this same leeway when hotplugging devices. On
top of that, current libvirt assumes that *all* devices are legacy
PCI. The result of all this is that it's impossible to hotplug a
device into a PCIe port, even if you manually add the PCI address.

This can all be traced to the function
virDomainPCIAddressEnsureAddr(), and the fact that it calls
virDomainPCIaddressReserveSlot() for manually set addresses, and that
function hardcodes the argument "fromConfig" to false (meaning "this
address was auto-assigned, so it should be subject to stricter
validation").

Since virDomainPCIAddressReserveSlot() is just a one line simple
wrapper around virDomainPCIAddressReserveAddr() (adding in a hardcoded
reserveEntireSlot = true and fromConfig = false), all that's needed to
solve the problem with no unwanted side effects is to replace that
call for virDomainPCIAddressReserveSlot() with a direct call to
virDomainPCIAddressReserveAddr(), but with reserveEntireSlot = true,
fromConfig = true. That's what this patch does.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1337490
2016-09-12 14:46:10 -04:00
Laine Stump
0276015325 qemu: fix improper initialization of cgroupControllers bitmap
virQEMUDriverConfigNew() always initializes the bitmap in its
cgroupControllers member to -1 (i.e. all 1's).

Prior to commit a9331394, if qemu.conf had a line with
"cgroup_controllers", cgroupControllers would get reset to 0 before
going through a loop setting a bit for each named cgroup controller.
commit a9331394 left out the "reset to 0" part, so cgroupControllers
would always be -1; if you didn't want a controller included, there
was no longer a way to make that happen.

This was discovered by users who were using qemu commandline
passthrough to use the "input-linux" method of directing
keyboard/mouse input to a virtual machine:

 https://www.redhat.com/archives/vfio-users/2016-April/msg00105.html

Here's the first report I found of the problem encountered after
upgrading libvirt beyond v2.0.0:

 https://www.redhat.com/archives/vfio-users/2016-August/msg00053.html

Thanks to sL1pKn07 SpinFlo <sl1pkn07@gmail.com> for bringing the
problem up in IRC, and then taking the time to do a git bisect and
find the patch that started the problem.
2016-09-12 14:40:22 -04:00
Martin Kletzander
94e2be8424 audit: Audit information about shmem devices
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1218603

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-09-12 19:41:43 +02:00
Daniel P. Berrange
92513bc23a qemu: avoid parameter named 'listen'
previous commit:

  commit 2c3223785c
  Author: John Ferlan <jferlan@redhat.com>
  Date:   Mon Jun 13 12:30:34 2016 -0400

    qemu: Add the ability to hotplug the TLS X.509 environment

added a parameter "bool listen" in some methods. This
unfortunately clashes with the listen() method, causing
compile failures on certain platforms (RHEL-6 for example)

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-09-12 15:49:28 +01:00
John Ferlan
2f6b750eca storage: Need to properly read the crypt offset value
Commit id 'a48c7141' altered how to determine if a volume was encrypted
by adding a peek at an offset into the file at a specific buffer location.
Unfortunately, all that was compared was the first "char" of the buffer
against the expect "int" value.

Restore the virReadBufInt32BE to get the complete field in order to
compare against the expected value from the qcow2EncryptionInfo or
qcow1EncryptionInfo "modeValue" field.

This restores the capability to create a volume with encryption, then
refresh the pool, and still find the encryption for the volume.
2016-09-12 10:05:21 -04:00
John Ferlan
b68487c917 storage: Need to refresh secret for luks volume after volume refresh
A LUKS volume uses the volume secret type just like the QCOW2 secret, so
adjust the loading of the default secrets to handle any volume that the
virStorageFileGetMetadataFromBuf code has deemed to be an encrypted volume
to search for the volume's secret. This lookup is done by volume usage
where the usage is expected to be the path to volume.
2016-09-12 10:05:21 -04:00
Nikolay Shirokovskiy
b6daacf6ce log: Fix reporting OOM error incorrectly when defining a logging filter
When a new filter is being defined, the return code is not handled properly,
thus triggering OOM error reporting routine (bug introduced by 51b2606f).

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-09-12 15:59:35 +02:00
Jiri Denemark
56258a388f qemu: Don't use query-migrate on destination
When migration fails, we need to poke QEMU monitor to check for a reason
of the failure. We did this using query-migrate QMP command, which is
not supposed to return any meaningful result on the destination side.
Thus if the monitor was still functional when we detected the migration
failure, parsing the answer from query-migrate always failed with the
following error message:

    "info migration reply was missing return status"

This irrelevant message was then used as the reason for the migration
failure replacing any message we might have had.

Let's use harmless query-status for poking the monitor to make sure we
only get an error if the monitor connection is broken.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-09-12 15:56:10 +02:00
John Ferlan
c8b8bbc366 util: Quiet the logging if perf file doesn't exist
Commit id 'b00d7f29' shifted the opening of the /sys/devices/intel_cqm/type
file from event enable to perf event initialization. If the file did not
exist, then an error would be written to the domain log:

2016-09-06 20:51:21.677+0000: 7310: error : virFileReadAll:1360 : Failed to open file '/sys/devices/intel_cqm/type': No such file or directory

Since the error is now handled in virPerfEventEnable by checking if the
event_attr->attrType == 0 for CMT, MBML, and MBMT events - we can just
use the Quiet API in order to not log the error we're going to throw away.

Additionally, rather than using virReportSystemError, use virReportError
and VIR_ERR_ARGUMENT_UNSUPPORTED in order to signify that support isn't there
for that type of perf event - adjust the error message as well.
2016-09-12 06:53:48 -04:00
Joao Martins
69f4030aad libxl: implement virConnectBaselineCPU
Akin to previous commit but for "virsh cpu-baseline" which
computes a baseline CPU for a set of host cpu elements.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-09-12 12:49:03 +02:00
Joao Martins
5822b740ad libxl: implement virConnectCompareCPU
Implement support for "virsh cpu-compare" so that we can calculate
common cpu element between a pool of hosts, which had a requirement
of providing host cpu description.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-09-12 12:49:03 +02:00
Joao Martins
17322e5518 libxl: describe host cpu features based on hwcaps
Parse libxl_hwcap accounting for versions since Xen 4.4 - Xen 4.7.
libxl_hwcaps is a set of cpuid leaves output that is described in [0] or
[1] in Xen 4.7. This is a collection of CPUID leaves that we version
in libvirt whenever feature words are reordered or added. Thus we keep the
common ones in one struct and others for each version. Since
libxl_hwcaps doesn't appear to have a stable format across all supported
versions thus we need to keep track of changes as a compromise until it's
exported in xen libxl API. We don't fail in initializing the driver in case
parsing of hwcaps failed for that reason. In addition, change the notation
on PAE feature such that is easier to read which bit it corresponds.

[0] xen/include/asm-x86/cpufeature.h
[1] xen/include/public/arch-x86/cpufeatureset.h

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
2016-09-12 12:49:03 +02:00
Joao Martins
3d54305e1c libxl: describe host topology in capabilities
Add support for describing cpu topology in host cpu element.  In doing
so, refactor hwcaps part to its own helper namely libxlCapsInitCPU to
handle all host cpu related operations, including topology.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
2016-09-12 12:49:03 +02:00
Peter Krempa
85c826129b qemu: hotplug: Don't wait if cdrom tray is opened forcibly
Qemu always opens the tray if forced to. Skip the waiting step in such
case.

This also helps if qemu does not report the tray change event when
opening the cdrom forcibly (the documentation says that the event will
not be sent although qemu in fact does trigger it even if @force is
selceted).

This is a workaround for a qemu issue where qemu does not send the tray
change event in some cases (after migration with empty closed locked
drive) and thus renders the cdrom useless from libvirt's point of view.

Partially resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1368368
2016-09-12 09:54:36 +02:00
Peter Krempa
6e19cc59a6 qemu: domain: Clear startup policy for dropped removable media
When a source image is dropped when missing due to startup policy the
policy needs to be cleared since it was relevant only for the given
storage source. New sources need to update it if needed.
2016-09-12 09:54:36 +02:00
Michal Privoznik
2692304c94 qemu: Implement virtio-net rx_queue_size
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-09-09 16:16:59 +02:00
Michal Privoznik
06d0969655 qemu_capabilities: Introduce virtio-net-*.rx_queue_size
Just like in the previous commit, teach qemu driver to detect
whether qemu supports this configuration knob or not.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-09-09 16:16:59 +02:00
Michal Privoznik
c56cdf2593 conf: Add support for virtio-net.rx_queue_size
https://bugzilla.redhat.com/show_bug.cgi?id=1366989

QEMU added another virtio-net tunable [1]. It basically allows
users to set the size of RX virtio ring. But because virtio-net
uses two separate ring buffers to pass data from/to guest they
named it explicitly rx_queue_size. We should expose it in our XML
too.

1: http://lists.nongnu.org/archive/html/qemu-devel/2016-08/msg02029.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-09-09 16:16:59 +02:00
John Ferlan
13350a17e4 conf: Add new secret type "tls"
Add a new secret usage type known as "tls" - it will handle adding the
secret objects for various TLS objects that need to provide some sort
of passphrase in order to access the credentials.

The format is:

   <secret ephemeral='no' private='no'>
     <description>Sample TLS secret</description>
     <usage type='tls'>
       <name>mumblyfratz</name>
     </usage>
</secret>

Once defined and a passphrase set, future patches will allow the UUID
to be set in the qemu.conf file and thus used as a secret for various
TLS options such as a chardev serial TCP connection, a NBD client/server
connection, and migration.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-09-09 08:20:05 -04:00
John Ferlan
2c3223785c qemu: Add the ability to hotplug the TLS X.509 environment
If the incoming XML defined a path to a TLS X.509 certificate environment,
add the necessary 'tls-creds-x509' object to the VIR_DOMAIN_CHR_TYPE_TCP
character device.

Likewise, if the environment exists the hot unplug needs adjustment as
well.  Note that all the return ret were changed to goto cleanup since
the cfg needs to be unref'd

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-09-09 08:09:47 -04:00
John Ferlan
ce61c16450 qemu: Add support for TLS X.509 path to TCP chardev backend
When building a chardev device string for tcp, add the necessary pieces to
access provide the TLS X.509 path to qemu.  This includes generating the
'tls-creds-x509' object and then adding the 'tls-creds' parameter to the
VIR_DOMAIN_CHR_TYPE_TCP command line.

Finally add the tests for the qemu command line. This test will make use
of the "new(ish)" /etc/pki/qemu setting for a TLS certificate environment
by *not* "resetting" the chardevTLSx509certdir prior to running the test.
Also use the default "verify" option (which is "no").

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-09-09 08:09:47 -04:00
John Ferlan
3f60a9c32f conf: Introduce chartcp_tls_x509_cert_dir
Add a new TLS X.509 certificate type - "chardev". This will handle the
creation of a TLS certificate capability (and possibly repository) for
properly configured character device TCP backends.

Unlike the vnc and spice there is no "listen" or "passwd" associated. The
credentials eventually will be handled via a libvirt secret provided to
a specific backend.

Make use of the default verify option as well.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-09-09 08:09:03 -04:00
John Ferlan
c12cb5ed73 conf: Add new default TLS X.509 certificate default directory
Rather than specify perhaps multiple TLS X.509 certificate directories,
let's create a "default" directory which can then be used if the service
(e.g. for now vnc and spice) does not supply a default directory.

Since the default for vnc and spice may have existed before without being
supplied, the default check will first check if the service specific path
exists and if so, set the cfg entry to that; otherwise, the default will
be set to the (now) new defaultTLSx509certdir.

Additionally add a "default_tls_x509_verify" entry which can also be used
to force the peer verification option (for vnc it's a x509verify option).
Add/alter the macro for the option being found in the config file to accept
the default value.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-09-09 07:09:49 -04:00
Jiri Denemark
66278d4bc3 qemu: Remove stale transient def when migration fails
If a migration of a domain which is already defined on the destination
host failed early (before we tried to start QEMU), we would forget to
remove the incoming transient definition. Later on when someone starts
the domain on the destination host, we will use the stale incoming
definition and the persistent definition will just be ignored.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-09-08 22:25:22 +02:00
Jiri Denemark
97a87333a0 Add helper for removing transient definition
The code for replacing domain's transient definition with the persistent
one is repeated in several places and we'll need to add one more. Let's
make a nice helper for it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-09-08 22:25:22 +02:00
Julio Faracco
fe94ee5db5 security: Fixing wrong label in virt-aa-helper.c.
There is an issue with a wrong label inside vah_add_path().
The compilation fails with the error:
make[3]: Entering directory '/tmp/libvirt/src'
  CC       security/virt_aa_helper-virt-aa-helper.o
security/virt-aa-helper.c: In function 'vah_add_path':
security/virt-aa-helper.c:769:9: error: label 'clean' used but not defined
         goto clean;

This patch moves 'clean' label to 'cleanup' label.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
2016-09-07 18:06:31 -04:00
Rufo Dogav
b3c1bcb9fd Avoid segfault in virt-aa-helper when handling read-only filesystems
This patch fixes a segfault in virt-aa-helper caused by attempting to
modify a static string literal. It is triggered when a domain has a
<filesystem> with type='mount' configured read-only and libvirt is
using the AppArmor security driver for sVirt confinement. An "R" is
passed into the function and converted to 'r'.
2016-09-07 16:29:02 -04:00
Peter Krempa
b871b78986 qemu: driver: Remove unnecessary condition
At this point it's guaranteed that 'persistentDef' is non-NULL so we
don't need to check it again.
2016-09-07 16:05:01 +02:00
Peter Krempa
68115fe0ab qemu: process: Fix start with unpluggable vcpus with NUMA pinning
Similarly to vcpu hotplug the emulator thread cgroup numa mapping needs
to be relaxed while hot-adding vcpus so that the threads can allocate
data in the DMA zone.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1370084
2016-09-07 16:05:01 +02:00
Peter Krempa
eb5dee3534 qemu: cgroup: Extract temporary relaxing of cgroup setting for vcpu hotplug
When hot-adding vcpus qemu needs to allocate some structures in the DMA
zone which may be outside of the numa pinning. Extract the code doing
this in a set of helpers so that it can be reused.
2016-09-07 16:05:01 +02:00
Maxim Nestratov
f47b91148a util: fix crash in virClassIsDerivedFrom for CloseCallbacks objects
There is a possibility that qemu driver frees by unreferencing its
closeCallbacks pointer as it has the only reference to the object,
while in fact not all users of CloseCallbacks called thier
virCloseCallbacksUnset.

Backtrace is the following:
Thread #1:
0  in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
1  in virCondWait (c=<optimized out>, m=<optimized out>)
    at util/virthread.c:154
2  in virThreadPoolFree (pool=0x7f0810110b50)
    at util/virthreadpool.c:266
3  in qemuStateCleanup () at qemu/qemu_driver.c:1116
4  in virStateCleanup () at libvirt.c:808
5  in main (argc=<optimized out>, argv=<optimized out>)
    at libvirtd.c:1660

Thread #2:
0  in virClassIsDerivedFrom (klass=0xdeadbeef, parent=0x7f0837c694d0) at util/virobject.c:169
1  in virObjectIsClass (anyobj=anyobj@entry=0x7f08101d4760, klass=<optimized out>) at util/virobject.c:365
2  in virObjectLock (anyobj=0x7f08101d4760) at util/virobject.c:317
3  in virCloseCallbacksUnset (closeCallbacks=0x7f08101d4760, vm=vm@entry=0x7f08101d47b0, cb=cb@entry=0x7f081d078fc0 <qemuProcessAutoDestroy>) at util/virclosecallbacks.c:163
4  in qemuProcessAutoDestroyRemove (driver=driver@entry=0x7f081018be50, vm=vm@entry=0x7f08101d47b0) at qemu/qemu_process.c:6368
5  in qemuProcessStop (driver=driver@entry=0x7f081018be50, vm=vm@entry=0x7f08101d47b0, reason=reason@entry=VIR_DOMAIN_SHUTOFF_SHUTDOWN, asyncJob=asyncJob@entry=QEMU_ASYNC_JOB_NONE, flags=flags@entry=0) at qemu/qemu_process.c:5854
6  in processMonitorEOFEvent (vm=0x7f08101d47b0, driver=0x7f081018be50) at qemu/qemu_driver.c:4585
7  qemuProcessEventHandler (data=<optimized out>, opaque=0x7f081018be50) at qemu/qemu_driver.c:4629
8  in virThreadPoolWorker (opaque=opaque@entry=0x7f0837c4f820) at util/virthreadpool.c:145
9  in virThreadHelper (data=<optimized out>) at util/virthread.c:206
10 in start_thread () from /lib64/libpthread.so.0

Let's reference CloseCallbacks object in virCloseCallbacksSet and
unreference in virCloseCallbacksUnset.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
2016-09-07 12:35:59 +03:00
Yuri Pudgorodskiy
914d5e1cbf qemu: guest agent: introduce new error code VIR_ERR_AGENT_UNSYNCED
A separate error code will help recognize real failures from
necessity to try again

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
2016-09-07 12:35:18 +03:00
Michal Privoznik
f3f15cc240 Make sure sys/types.h is included after sys/sysmacros.h
In the latest glibc, major() and minor() functions are marked as
deprecated (glibc commit dbab6577):

  CC       util/libvirt_util_la-vircgroup.lo
util/vircgroup.c: In function 'virCgroupGetBlockDevString':
util/vircgroup.c:768:5: error: '__major_from_sys_types' is deprecated:
  In the GNU C Library, `major' is defined by <sys/sysmacros.h>.
  For historical compatibility, it is currently defined by
  <sys/types.h> as well, but we plan to remove this soon.
  To use `major', include <sys/sysmacros.h> directly.
  If you did not intend to use a system-defined macro `major',
  you should #undef it after including <sys/types.h>.
  [-Werror=deprecated-declarations]
     if (virAsprintf(&ret, "%d:%d ", major(sb.st_rdev), minor(sb.st_rdev)) < 0)
     ^~
In file included from /usr/include/features.h:397:0,
                 from /usr/include/bits/libc-header-start.h:33,
                 from /usr/include/stdio.h:28,
                 from ../gnulib/lib/stdio.h:43,
                 from util/vircgroup.c:26:
/usr/include/sys/sysmacros.h:87:1: note: declared here
 __SYSMACROS_DEFINE_MAJOR (__SYSMACROS_FST_IMPL_TEMPL)
 ^

Moreover, in the glibc commit, there's suggestion to keep
ordering of including of header files as implemented here.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-09-06 17:49:36 +02:00
Roman Bogorodskiy
f8435a434a util: hostcpu: improve CPU freq code for FreeBSD
Current implementation uses the dev.cpu.0.freq sysctl that is
provided by the cpufreq(4) framework and returns the actual
CPU frequency. However, there are environments where it's not available,
e.g. when running nested in KVM. In this case fall back to hw.clockrate
that reports CPU frequency at the boot time.

Resolves (hopefully):
https://bugzilla.redhat.com/show_bug.cgi?id=1369964
2016-09-06 18:27:56 +03:00
Andrea Bolognani
839a060890 virtlogd.socket: Tie lifecycle to libvirtd.service
We already guarantee that virtlogd.socket is enabled/disabled
along with libvirtd.service, but if libvirtd.service has just
been installed and is started before rebooting, then
virtlogd.socket will not be running and guest startup will
fail.

Add Requires=virtlogd.socket to libvirtd.service to make sure
virtlogd.socket is always started along with libvirtd.service,
and add Before=libvirtd.service to both virtlogd.socket and
virtlogd.service so that virtlogd never disappears before
libvirtd has exited.

Also add PartOf=libvirtd.service to both virtlogd.socket and
virtlogd.service, so that virtlogd can be shut down when not
needed.

Resolves: https://bugzilla.redhat.com/1372576
2016-09-06 16:05:20 +02:00
Jiri Denemark
5ead7f939a qemu: Don't warn about missing device in DEVICE_DELETED event
Debug priority is good enough for this.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-09-06 14:30:40 +02:00
Daniel P. Berrange
90e178f8bf qemu: allow turning off QEMU guest RAM dump globally
We already have the ability to turn off dumping of guest
RAM via the domain XML. This is not particularly useful
though, as it is under control of the management application.
What is needed is a way for the sysadmin to turn off guest
RAM defaults globally, regardless of whether the mgmt app
provides its own way to set this in the domain XML.

So this adds a 'dump_guest_core' option in /etc/libvirt/qemu.conf
which defaults to false. ie guest RAM will never be included in
the QEMU core dumps by default. This default is different from
historical practice, but is considered to be more suitable as
a default because

 a) guest RAM can be huge and so inflicts a DOS on the host
    I/O subsystem when dumping core for QEMU crashes

 b) guest RAM can contain alot of sensitive data belonging
    to the VM owner. This should not generally be copied
    around inside QEMU core dumps submitted to vendors for
    debugging

 c) guest RAM contents are rarely useful in diagnosing
    QEMU crashes

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-09-06 13:08:30 +01:00
Daniel P. Berrange
fa1ce97917 qemu: add a max_core setting to qemu.conf for core dump size
Currently the QEMU processes inherit their core dump rlimit
from libvirtd, which is really suboptimal. This change allows
their limit to be directly controlled from qemu.conf instead.
2016-09-06 13:08:30 +01:00
Peter Krempa
3de7da9448 util: storage: Add json pseudo protocol support for legacy RBD strings
RBD in qemu still uses only the legacy 'filename' syntax.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1371758
2016-09-06 14:01:41 +02:00
Peter Krempa
b7a650c97c util: storage: Properly set protocol type when parsing gluster json string
Commit 2ed772cd forgot to set proper protocol. This was also present in
the test data.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1372251
2016-09-06 14:01:41 +02:00
Qiaowei Ren
bae660869d perf: add more perf events support
With current perf framework, this patch adds support and documentation
for more perf events, including cache misses, cache references, cpu cycles,
and instructions.

Signed-off-by: Qiaowei Ren <qiaowei.ren@intel.com>
2016-09-02 17:00:58 -04:00
Qiaowei Ren
b00d7f298b perf: Adjust the perf initialization
Introduce a static attr table and refactor virPerfEventEnable() for
general purpose usage.

This patch creates a static table/matrix that converts the VIR_PERF_EVENT_*
events into their respective "attr.type" and "attr.config" so that
virPerfEventEnable doesn't have the switch the calling function passes
by value the 'type'.

Signed-off-by: Qiaowei Ren <qiaowei.ren@intel.com>
2016-09-02 17:00:58 -04:00
John Ferlan
63358e0b87 util: Move virPerfNew and virPerfFree
Move them to the bottom under the #ifdef code.
2016-09-02 17:00:58 -04:00
Qiaowei Ren
c2f061c861 util: Add some comment details for virPerfEventType
Add to some details for the existing enum
2016-09-02 17:00:58 -04:00
Qiaowei Ren
062f413928 perf: Remove the switch from qemuDomainGetStatsPerf
Remove the unnecessary switch since all VIR_PERF_EVENT* values are fetched
2016-09-02 17:00:58 -04:00
Qiaowei Ren
f52b24d837 perf: rename qemuDomainGetStatsPerfRdt()
This patch rename qemuDomainGetStatsPerfRdt() to
qemuDomainGetStatsPerfOneEvent()

Signed-off-by: Qiaowei Ren <qiaowei.ren@intel.com>
2016-09-02 17:00:58 -04:00
Nikolay Shirokovskiy
c62e79c8ca qemu: Filter cur_balloon ABI check for certain transactions
Since the domain lock is not held during preparation of an external XML
config, it is possible that the value can change resulting in unexpected
failures during ABI consistency checking for some save and migrate
operations.

This patch adds a new flag to skip the checking of the cur_balloon value
and then sets the destination value to the source value to ensure
subsequent checks without the skip flag will succeed.

This way it is protected from forges and is keeped up to date too.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-09-02 16:54:42 -04:00
Bob Liu
faaebe1795 xenconfig: rm format/parse multi serial for xen-xm
xen-xm doesn't support multi serial at all, this patch drop the
domXML <-> xl.cfg conversions.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
2016-09-02 12:46:02 -06:00
Bob Liu
846a1c6473 libxl: support serial list
Add support for multi serial devices, after this patch virsh can be used to
connect different serial devices of running domains. E.g.
vish # console <xxx> --devname serial<xxx>

Note:
This depends on a xen/libxl bug fix to have libxl_console_get_tty(...) correctly
returning the tty path (as opposed to always returning the first one).
[0] https://lists.xen.org/archives/html/xen-devel/2016-08/msg00438.html

Signed-off-by: Bob Liu <bob.liu@oracle.com>
2016-09-02 12:46:02 -06:00
Jim Fehlig
70f83f9d52 virpci: support driver_override sysfs interface
libvirt uses the new_id PCI sysfs interface to bind a PCI stub driver
to a PCI device. The new_id interface is known to be buggy and racey,
hence a more deterministic interface was introduced in the 3.12 kernel:
driver_override. For more details see

https://www.redhat.com/archives/libvir-list/2016-June/msg02124.html

For more details about the driver_override interface and examples of
its usage, see

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/pci/pci-driver.c?h=v3.12&id=782a985d7af26db39e86070d28f987cad21313c0

This patch adds support for the driver_override interface by

- adding new virPCIDevice{BindTo,UnbindFrom}StubWithOverride functions
  that use the driver_override interface
- renames the existing virPCIDevice{BindTo,UnbindFrom}Stub functions
  to virPCIDevice{BindTo,UnbindFrom}StubWithNewid to perserve existing
  behavior on new_id interface
- changes virPCIDevice{BindTo,UnbindFrom}Stub function to call one of
  the above depending on availability of driver_override

The patch includes a bit of duplicate code, but allows for easily
dropping the new_id code once support for older kernels is no
longer desired.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2016-09-02 11:47:23 -06:00
Cédric Bosdonnat
e01d300bb1 libxl: allow vendor/product addressing for USB hostdevs
libxl only has API to address the host USB devices by bus/device.
Find the bus/device if the user only provided the vendor/product
of the USB device.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2016-09-02 17:38:15 +02:00
Cédric Bosdonnat
ea46e00f12 Add virHostdevFindUSBDevice to private symbols
Finding an USB device from the vendor/device values will be needed
by libxl driver to convert from vendor/device to bus/dev addresses.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2016-09-02 17:38:09 +02:00
Xian Han Yu
f7658da6b3 conf: Fix initialization value of 'multi' in PCI address
The 'multi' element in PCI address struct used as 'virTristateSwitch',
and its default value is 'VIR_TRISTATE_SWITCH_ABSENT'. Current PCI
process use 'false' to initialization 'multi', which is ambiguously
for assignment or comparison. This patch use '{0}' to initialize
the whole PCI address struct, which fix the 'multi' initialization
and makes code more simplify and explicitly.

Signed-off-by: Xian Han Yu <xhyubj@linux.vnet.ibm.com>
2016-09-02 16:43:00 +02:00
Jim Fehlig
36f57ad7d7 libxl: advertise support for migration V3
The libxl driver has long supported migration V3 but has never
indicated so in the connectSupportsFeature API. As a result, apps
such as virt-manager that use the more generic virDomainMigrate API
fail with

libvirtError: this function is not supported by the connection driver:
virDomainMigrate

Add VIR_DRV_FEATURE_MIGRATION_V3 to the list of features marked as
supported in the connectSupportsFeature API.
2016-08-29 10:08:01 -06:00
Roman Bogorodskiy
6114807477 tests: fix segfault in objecteventtest
Test 12 from objecteventtest (createXML add event) segaults on FreeBSD
with bus error.

At some point it calls testNodeDeviceDestroy() from the test driver. And
it fails when it tries to unlock the device in the "out:" label of this
function.

Unlocking fails because the previous step was a call to
virNodeDeviceObjRemove from conf/node_device_conf.c. This function
removes the given device from the device list and cleans up the object,
including destroying of its mutex. However, it does not nullify the pointer
that was given to it.

As a result, we end up in testNodeDeviceDestroy() here:

 out:
    if (obj)
        virNodeDeviceObjUnlock(obj);

And instead of skipping this, we try to do Unlock and fail because of
malformed mutex.

Change virNodeDeviceObjRemove to use double pointer and set pointer to
NULL.
2016-08-29 13:51:56 +03:00
Roman Bogorodskiy
25ee22bdbc bhyve: fix disks address allocation
As bhyve currently doesn't use controller addressing and simply
uses 1 implicit controller for 1 disk device, the scheme looks the
following:

 pci addrees -> (implicit controller) -> disk device

So in fact we identify disk devices by pci address of implicit
controller and just pass it this way to bhyve in a form:

 -s pci_addr,ahci-(cd|hd),/path/to/disk

Therefore, we cannot use virDeviceInfoPCIAddressWanted() because it
does not expect that disk devices might need PCI address assignment.

As a result, if a disk was specified without address, it will not be
generated and domain will to start.

Until proper controller addressing is implemented in the bhyve
driver, force each disk to have PCI address generated if it was not
specified by user.
2016-08-29 09:37:06 +03:00
Peter Krempa
9cf086be6d conf: Fix build with picky GCC
../../src/conf/domain_conf.c:4425:21: error: potential null pointer dereference [-Werror=null-dereference]
         switch (vcpu->hotpluggable) {
                 ~~~~^~~~~~~~~~~~~~
2016-08-26 11:32:38 -04:00
Peter Krempa
802fac97ec qemu: driver: Validate configuration when setting maximum vcpu count
Setting vcpu count when cpu topology is specified may result into an
invalid configuration. Since the topology can't be modified, reject the
setting if it doesn't match the requested topology. This will allow
fixing the topology in case it was broken.

Partially fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1370066
2016-08-26 11:30:17 -04:00
Peter Krempa
c9cb35c255 conf: Don't validate vcpu count in XML parser
Validating the vcpu count is more intricate and doing it in the XML
parser will make previously valid configs (with older qemus) vanish.

Now that we have a very similar check in the qemu domain validation
callback we can do it in a more appropriate place.

This basically reverts commit b54de0830a.

Partially resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1370066
2016-08-26 11:26:59 -04:00
Peter Krempa
9b6e947b01 qemu: driver: Fix qemuDomainHelperGetVcpus for sparse vcpu topologies
ce43cca0e refactored the helper to prepare it for sparse topologies but
forgot to fix the iterator used to fill the structures. This would
result into a weirdly sparse populated array and possible out of bounds
access and crash once sparse vcpu topologies were allowed.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1369988
2016-08-26 11:23:00 -04:00
Mikhail Feoktistov
0c3e499c78 vz: getting bus type for containers
We should query bus type for containers too, like for VM.
In openstack we add volume disk like SCSI, so we can't
hardcode SATA bus.
2016-08-26 17:48:55 +03:00
Nikolay Shirokovskiy
836a2c78ca vz: update domain cache after device updates 2016-08-26 17:48:29 +03:00
Olga Krishtal
3a6cf6fc16 vz: fixed race in vzDomainAttach/DettachDevice
While dettaching/attaching device in OpenStack, nova
calls vzDomainDettachDevice twice, because the update of the internal
configuration of the ct comes a bit latter than the update event.
As the result, we suffer from the second call to dettach the same device.

Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
2016-08-26 17:48:12 +03:00
Pavel Glushchak
2354266acf vz: added VIR_MIGRATE_PARAM_BANDWIDTH param handling
libvirt-python passes parameter bandwidth = 0
by default. This means that bandwidth is unlimited.
VZ driver doesn't support bandwidth rate limiting,
but we still need to handle it and fail if bandwidth > 0.

Signed-off-by: Pavel Glushchak <pglushchak@virtuozzo.com>
2016-08-26 14:59:22 +03:00
Pavel Glushchak
d7af2218b6 vz: implicitly support additional migration flags
* Added VIR_MIGRATE_LIVE, VIR_MIGRATE_UNDEFINE_SOURCE and
  VIR_MIGRATE_PERSIST_DEST to supported migration flags

Signed-off-by: Pavel Glushchak <pglushchak@virtuozzo.com>
2016-08-26 14:59:13 +03:00
Laine Stump
0726222123 qemu: set tap device online for type='ethernet'
When support for auto-creating tap devices was added to <interface
type='ethernet'> in commit 9c17d6, the code assumed that
virNetDevTapCreate() would honor the VIR_NETDEV_TAP__CREATE_IFUP flag
that is supported by virNetDevTapCreateInBridgePort(). That isn't the
case - the latter function performs several operations, and one of
them is setting the tap device online. But virNetDevTapCreate() *only*
creates the tap device, and relies on the caller to do everything
else, so qemuInterfaceEthernetConnect() needs to call
virNetDevSetOnline() after the device is successfully created.
2016-08-25 18:54:01 -04:00
Laine Stump
dbb7903932 qemu: remove unnecessary setting of tap device online state
The linkstate setting of an <interface> is only meant to change the
online status reported to the guest system by the emulated network
device driver in qemu, but when support for auto-creating tap devices
for <interface type='ethernet'> was added in commit 9717d6, a chunk of
code was also added to qemuDomainChangeNetLinkState() that sets the
online status of the tap device (i.e. the *host* side of the
interface) for type='ethernet'. This was never done for tap devices
used in type='bridge' or type='network' interfaces, nor was it done in
the past for tap devices created by external scripts for
type='ethernet', so we shouldn't be doing it now.

This patch removes the bit of code in qemuDomainChangeNetLinkState()
that modifies online status of the tap device.
2016-08-25 18:51:51 -04:00
Vasiliy Tolstov
5f243153c5 qemu: fix ethernet network type ip/route assign
The call to virNetDevIPInfoAddToDev() that sets up tap device IP
addresses and routes was somehow incorrectly placed in
qemuInterfaceStopDevice() instead of qemuInterfaceStartDevice() in
commit fe8567f6.  This fixes that error by moving the call to
virNetDevIPInfoAddToDev() to qemuInterfaceStartDevice().

Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
2016-08-25 18:51:12 -04:00
Peter Krempa
e3229f6e44 qemu: hotplug: Add support for VCPU unplug
This patch removes the old vcpu unplug code completely and replaces it
with the new code using device_del. The old hotplug code basically never
worked with any recent qemu and thus is useless.

As the new code is using device_del all the implications of using it
are present. Contrary to the device deletion code, the vcpu deletion
code fails if the unplug request is not executed in time.
2016-08-24 15:44:47 -04:00
Peter Krempa
00990d9f4c qemu: hotplug: Allow marking unplugged devices by alias
Add a overlay function that takes the alias directly rather than
extracting it from a device info.
2016-08-24 15:44:47 -04:00
Peter Krempa
6d4ee77d75 qemu: Use modern vcpu hotplug approach if possible
To allow unplugging the vcpus, hotplugging of vcpus on platforms which
require to plug multiple logical vcpus at once or plugging them in an
arbitrary order it's necessary to use the new device_add interface for
vcpu hotplug.

This patch adds support for the device_add interface using the old
setvcpus API by implementing an algorithm to select the appropriate
entities to plug in.
2016-08-24 15:44:47 -04:00
Peter Krempa
9eb9106ea5 qemu: command: Add support for sparse vcpu topologies
Add support for using the new approach to hotplug vcpus using device_add
during startup of qemu to allow sparse vcpu topologies.

There are a few limitations imposed by qemu on the supported
configuration:
- vcpu0 needs to be always present and not hotpluggable
- non-hotpluggable cpus need to be ordered at the beginning
- order of the vcpus needs to be unique for every single hotpluggable
  entity

Qemu also doesn't really allow to query the information necessary to
start a VM with the vcpus directly on the commandline. Fortunately they
can be hotplugged during startup.

The new hotplug code uses the following approach:
- non-hotpluggable vcpus are counted and put to the -smp option
- qemu is started
- qemu is queried for the necessary information
- the configuration is checked
- the hotpluggable vcpus are hotplugged
- vcpus are started

This patch adds a lot of checking code and enables the support to
specify the individual vcpu element with qemu.
2016-08-24 15:44:47 -04:00
Peter Krempa
20ef1232ec qemu: process: Copy final vcpu order information into the vcpu definition
The vcpu order information is extracted only for hotpluggable entities,
while vcpu definitions belonging to the same hotpluggable entity need
to all share the order information.

We also can't overwrite it right away in the vcpu info detection code as
the order is necessary to add the hotpluggable vcpus enabled on boot in
the correct order.

The helper will store the order information in places where we are
certain that it's necessary.
2016-08-24 15:44:47 -04:00
Peter Krempa
8807f28b85 qemu: command: Add helper to convert vcpu definition to JSON props
For use on the monitor we need to format certain parts of the vcpu
private definition into a JSON object. Add a helper.
2016-08-24 15:44:47 -04:00
Peter Krempa
48e3d42889 qemu: migration: Prepare for non-contiguous vcpu configurations
Introduce a new migration cookie flag that will be used for any
configurations that are not compatible with libvirt that would not
support the specific vcpu hotplug approach. This will make sure that old
libvirt does not fail to reproduce the configuration correctly.
2016-08-24 15:44:47 -04:00
Peter Krempa
5847bc5c64 conf: Add XML for individual vCPU hotplug
Individual vCPU hotplug requires us to track the state of any vCPU. To
allow this add the following XML:

<domain>
  ...
  <vcpu current='2'>3</vcpu>
  <vcpus>
    <vcpu id='0' enabled='yes' hotpluggable='no' order='1'/>
    <vcpu id='1' enabled='yes' hotpluggable='yes' order='2'/>
    <vcpu id='1' enabled='no' hotpluggable='yes'/>
  </vcpus>
  ...

The 'enabled' attribute allows to control the state of the vcpu.
'hotpluggable' controls whether given vcpu can be hotplugged and 'order'
allows to specify the order to add the vcpus.
2016-08-24 15:44:47 -04:00
Peter Krempa
c84c2cb389 util: Extract and rename qemuDomainDelCgroupForThread to virCgroupDelThread 2016-08-24 15:44:47 -04:00
Peter Krempa
133be0a9e2 qemu: domain: Prepare for VCPUs vanishing while libvirt is not running
Similarly to devices the guest may allow unplug of the VCPU if libvirt
is down. To avoid problems, refresh the vcpu state on reconnect. Don't
mess with the vcpu state otherwise.
2016-08-24 15:44:47 -04:00
Peter Krempa
6b4a23ff6c qemu: domain: Extract cpu-hotplug related data
Now that the monitor code gathers all the data we can extract it to
relevant places either in the definition or the private data of a vcpu.

As only thread id is broken for TCG guests we may extract the rest of
the data and just skip assigning of the thread id. In case where qemu
would allow cpu hotplug in TCG mode this will make it work eventually.
2016-08-24 15:44:47 -04:00
Peter Krempa
9bbbc88a8f qemu: monitor: Add algorithm for combining query-(hotpluggable-)-cpus data
For hotplug purposes it's necessary to retrieve data using
query-hotpluggable-cpus while the old query-cpus API report thread IDs
and order of hotplug.

This patch adds code that merges the data using a rather non-trivial
algorithm and fills the data to the qemuMonitorCPUInfo structure for
adding to appropriate place in the domain definition.
2016-08-24 15:44:47 -04:00
Peter Krempa
1213f0f8a5 qemu: monitor: Add support for calling query-hotpluggable-cpus
Add support for retrieving information regarding hotpluggable cpu units
supported by qemu. Data returned by the command carries information
needed to figure out the granularity of hotplug, the necessary cpu type
name and the topology information.

Note that qemu doesn't specify any particular order of the entries thus
it's necessary sort them by socket_id, core_id and thread_id to the
order libvirt expects.
2016-08-24 15:44:47 -04:00
Peter Krempa
c91be16b9f qemu: monitor: Extract QOM path from query-cpus reply
To allow matching up the data returned by query-cpus to entries in the
query-hotpluggable-cpus reply for CPU hotplug it's necessary to extract
the QOM path as it's the only link between the two.
2016-08-24 15:44:47 -04:00
Peter Krempa
920bbe5c15 qemu: capabilities: Extract availability of new cpu hotplug for machine types
QEMU reports whether 'query-hotpluggable-cpus' is supported for a given
machine type. Extract and cache the information using the capability
cache.

When copying the capabilities for a new start of qemu, mask out the
presence of QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS if the machine type
doesn't support hotpluggable cpus.
2016-08-24 15:44:47 -04:00
Peter Krempa
ffa536e0f8 qemu: Forbid config when topology based cpu count doesn't match the config
As of qemu commit:
commit a32ef3bfc12c8d0588f43f74dcc5280885bbdb30
Author: Thomas Huth <thuth@redhat.com>
Date:   Wed Jul 22 15:59:50 2015 +0200

    vl: Add another sanity check to smp_parse() function

v2.4.0-952-ga32ef3b

configuration where the maximum CPU count doesn't match the topology is
rejected. Prior to that only configurations where the topology would
contain more cpus than the maximum count would be rejected.

Use QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS as a relevant recent enough
witness to avoid breaking old configs.
2016-08-24 15:44:47 -04:00
Peter Krempa
f17ddfeee3 qemu: Add capability for query-hotpluggable-cpus command 2016-08-24 15:44:47 -04:00
Peter Krempa
b3180425ce qemu: monitor: Return struct from qemuMonitor(Text|Json)QueryCPUs
Prepare to extract more data by returning an array of structs rather than
just an array of thread ids. Additionally report fatal errors separately
from qemu not being able to produce data.
2016-08-24 15:44:47 -04:00
Peter Krempa
5b5f494a1b qemu: monitor: Return structures from qemuMonitorGetCPUInfo
The function will gradually add more returned data. Return a struct for
every vCPU containing the data.
2016-08-24 15:44:47 -04:00
Chen Hanxiao
6de1d22cca storage_backend_rbd: fix typos
s/failed/failed to

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
2016-08-24 21:25:17 +02:00
Peter Krempa
c74cae234e Fix remote_protocol-structs after recent commit
Commit 0adc9d26ae broke the build since
remote_protocol-structs was not updated.
2016-08-23 15:47:10 -04:00
Nikolay Shirokovskiy
018b4ae14b vz: add ACL checks to API calls
vzDomainMigrateConfirm3Params is whitelisted. Otherwise we need to
move removing domain from domain list from perform to confirm
step. This would further imply adding a flag and check that migration
is in progress to prohibit mistakenly (maliciously) removing domains
on confirm step. vz version of p2p also need to be fixed to include confirm step.
One would also need to add means to cleanup pending migration
on client disconnect as now is has state across several API
calls.

  On the other hand current version of confirm step is totaly
harmless thus it is easier to whitelist it at the moment.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
2016-08-23 19:48:01 +03:00
Nikolay Shirokovskiy
0adc9d26ae remote: rename protocol names for close callbacks
This way we make naming consistent to API calls and make subsequent
ACL checks possible (otherwise ACL check would discover name
discrepancies).

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-08-23 19:48:01 +03:00
Nikolay Shirokovskiy
5a435726ef vz: prepare migration for ACL checks
ACL check on perform step should be in API call itself to make ACL
checking script pass. Thus we need to reorganize code to obtain
domain object in perform API itself. Most of this is straight
forward, the only nuance is dropping locks on lengthy remote
operations.
  The other motivation is to have only perform step ACL checks for
p2p migration instead of both begin in perform if we can leave
ACL check in vzDomainMigratePerformStep.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-08-23 19:48:01 +03:00
Nikolay Shirokovskiy
5a78ef91fa vz: expand setting memory API calls
We need it to prepare the calls for ACL checks otherwise ACL checking
script will fail.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-08-23 19:48:01 +03:00
Nikolay Shirokovskiy
a041ae571d vz: add missing flagged versions of API functions
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-08-23 19:48:01 +03:00
Nikolay Shirokovskiy
1a28c5e007 vz: factor out converting block stats to params
This action deserves its own function and makes main API call
structure much cleaner.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-08-23 19:48:01 +03:00
Nikolay Shirokovskiy
1b2673e2b0 vz: factor out block stats impl
Now we can use intended ACL check for both API calls.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-08-23 19:48:01 +03:00
Nikolay Shirokovskiy
4cdf203263 vz: implement plain create API thru createFlags instead of visa versa
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-08-23 19:48:01 +03:00
Nikolay Shirokovskiy
db66c35e2e vz: expand start/stop/... APIs for ACL checks
The original motivation is to expand API calls like start/stop etc so that
the ACL checks could be added. But this patch has its own befenits.

1. functions like prlsdkStart/Stop use common routine to wait for
job without domain lock. They become more self contained and do
not return intermediate PRL_RESULT.

2. vzDomainManagedSave do not update cache twice.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
2016-08-23 19:48:01 +03:00
John Ferlan
02483b1dca network: Need to free formatted addr in networkDnsmasqConfContents
Commit id '0b6336c2' formatted the 'addr', but didn't VIR_FREE it.

Found by Coverity.
2016-08-22 13:14:15 -04:00
JieWang
f9edff30fe remove the dead code this patch is to remove the dead code Signed-off-by: JieWang <wangjie88@huawei.com>
Signed-off-by: JieWang <wangjie88@huawei.com>
2016-08-22 13:20:43 +01:00
John Ferlan
b4478c16c0 qemu: Fix crash hot plugging luks volume
https://bugzilla.redhat.com/show_bug.cgi?id=1367259

Crash occurs because 'secrets' is being dereferenced in call:

        if (qemuDomainSecretSetup(conn, priv, secinfo, disk->info.alias,
                                  VIR_SECRET_USAGE_TYPE_VOLUME, NULL,
                                  &src->encryption->secrets[0]->seclookupdef,
                                  true) < 0)

(gdb) p *src->encryption
$1 = {format = 2, nsecrets = 0, secrets = 0x0, encinfo = {cipher_size = 0,
    cipher_name = 0x0, cipher_mode = 0x0, cipher_hash = 0x0, ivgen_name = 0x0,
    ivgen_hash = 0x0}}
(gdb) bt
    priv=priv@entry=0x7fffc03be160, disk=disk@entry=0x7fffb4002ae0)
    at qemu/qemu_domain.c:1087
    disk=0x7fffb4002ae0, vm=0x7fffc03a2580, driver=0x7fffc02ca390,
    conn=0x7fffb00009a0) at qemu/qemu_hotplug.c:355

Upon entry to qemuDomainAttachVirtioDiskDevice, src->encryption points
at a valid 'secret' buffer w/ nsecrets == 1; however, the call to
qemuDomainDetermineDiskChain will call virStorageFileGetMetadata
and eventually virStorageFileGetMetadataInternal where the src->encryption
was overwritten when probing the volume.

Commit id 'a48c7141' added code to virStorageFileGetMetadataInternal
to determine if the disk/volume would use/need encryption and allocated
a meta->encryption. This overwrote an existing encryption buffer
already provided by the XML

This patch adds a check for meta->encryption already present before
just allocating and overwriting an existing buffer. It then checks the
existing encryption data to ensure the XML provided format for the
disk matches the expected format read from the disk and errors if there
is a mismatch.
2016-08-20 08:21:19 -04:00
Laine Stump
0b6336c2d9 network: allow limiting a <forwarder> element to certain domains
For some unknown reason the original implementation of the <forwarder>
element only took advantage of part of the functionality in the
dnsmasq feature it exposes - it allowed specifying the ip address of a
DNS server which *all* DNS requests would be forwarded to, like this:

   <forwarder addr='192.168.123.25'/>

This is a frontend for dnsmasq's "server" option, which also allows
you to specify a domain that must be matched in order for a request to
be forwarded to a particular server. This patch adds support for
specifying the domain. For example:

   <forwarder domain='example.com' addr='192.168.1.1'/>
   <forwarder domain='www.example.com'/>
   <forwarder domain='travesty.org' addr='10.0.0.1'/>

would forward requests for bob.example.com, ftp.example.com and
joe.corp.example.com all to the DNS server at 192.168.1.1, but would
forward requests for travesty.org and www.travesty.org to
10.0.0.1. And due to the second line, requests for www.example.com,
and odd.www.example.com would be resolved by the libvirt network's own
DNS server (i.e. thery wouldn't be immediately forwarded) even though
they also match 'example.com' - the match is given to the entry with
the longest matching domain. DNS requests not matching any of the
entries would be resolved by the libvirt network's own DNS server.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1331796
2016-08-19 21:34:51 -04:00
Laine Stump
9065cfaa88 network: allow disabling dnsmasq's DNS server
If you define a libvirt virtual network with one or more IP addresses,
it starts up an instance of dnsmasq. It's always been possible to
avoid dnsmasq's dhcp server (simply don't include a <dhcp> element),
but until now it wasn't possible to avoid having the DNS server
listening; even if the network has no <dns> element, it is started
using default settings.

This patch adds a new attribute to <dns>: enable='yes|no'. For
backward compatibility, it defaults to 'yes', but if you don't want a
DNS server created for the network, you can simply add:

   <dns enable='no'/>

to the network configuration, and next time the network is started
there will be no dns server created (if there is dhcp configuration,
dnsmasq will be started with "port=0" which disables the DNS server;
if there is no dhcp configuration, dnsmasq won't be started at all).
2016-08-19 21:10:34 -04:00
Laine Stump
25e8112d7c network: new network forward mode 'open'
The new forward mode 'open' is just like mode='route', except that no
firewall rules are added to assure that any traffic does or doesn't
pass. It is assumed that either they aren't necessary, or they will be
setup outside the scope of libvirt.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=846810
2016-08-19 21:05:15 -04:00