Commit Graph

14210 Commits

Author SHA1 Message Date
Peter Krempa
ee591240c2 qemu: monitor: Ensure that qemuMonitorSetLink is called with non-null name 2015-04-15 13:58:26 +02:00
Peter Krempa
0e9fadd66d qemu: monitor: Sanitize control flow in qemuMonitorSetCapabilities 2015-04-15 13:58:26 +02:00
Peter Krempa
119aa5d35a qemu: monitor: Clean up coding style
Fix line spacing between functions, ensure that function return type is
on a separate line and reflow arguments for VIR_DEBUG statements.
2015-04-15 13:58:25 +02:00
Michal Privoznik
be78814ae0 virNetSocketNewConnectUNIX: Use flocks when spawning a daemon
https://bugzilla.redhat.com/show_bug.cgi?id=1200149

Even though we have a mutex mechanism so that two clients don't spawn
two daemons, it's not strong enough. It can happen that while one
client is spawning the daemon, the other one fails to connect.
Basically two possible errors can happen:

  error: Failed to connect socket to '/home/mprivozn/.cache/libvirt/libvirt-sock': Connection refused

or:

  error: Failed to connect socket to '/home/mprivozn/.cache/libvirt/libvirt-sock': No such file or directory

The problem in both cases is, the daemon is only starting up, while we
are trying to connect (and fail). We should postpone the connecting
phase until the daemon is started (by the other thread that is
spawning it). In order to do that, create a file lock 'libvirt-lock'
in the directory where session daemon would create its socket. So even
when called from multiple processes, spawning a daemon will serialize
on the file lock. So only the first to come will spawn the daemon.

Tested-by: Richard W. M. Jones <rjones@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-15 13:39:13 +02:00
Martin Kletzander
bb6a62d4ab json: export non-static functions
Two non-static functions in virjson.c were missing their export info in
libvirt_private.syms, so they couldn't be used anywhere it the code (and
that's about to get changed).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-04-15 13:33:35 +02:00
Martin Kletzander
fae5b555c8 Change virConnectPtr into virObjectLocklable
It already had a virMutex inside, so this is just a cleanup.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-04-15 13:33:35 +02:00
Martin Kletzander
6dfbaca7b7 closeCallback is already lockable, initialize it as such
Luckily we are allocating structs as clean memory and
PTHREAD_MUTEX_INITIALIZER is "{ 0 }", so nothing happened, but it should
still be created as lockable object.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-04-15 13:33:35 +02:00
John Ferlan
5817451947 storage: Add duplicate devices check for zfs pool def
Check proposed pool definitions to ensure they aren't trying to use the
same devices as currently defined definitions - disallow the duplicate
2015-04-15 06:51:20 -04:00
John Ferlan
2184ade3a0 storage: Add duplicate source pool for Gluster pool def
Check the proposed pool source host XML definition against existing gluster
pools to ensure the incoming definition doesn't use the same source dir and
soure host XML definition as an existing pool.
2015-04-15 06:50:27 -04:00
John Ferlan
521add056e storage: Add duplicate host check for Sheepdog pool def
Check the proposed pool source host XML definition against existing sheepdog
pools to ensure the incoming definition doesn't use the same source host XML
definition as an existing pool.
2015-04-15 06:40:08 -04:00
John Ferlan
556a21f9fb storage: Remove default from switch in virStoragePoolSourceFindDuplicate
So that we can cover all the cases.
2015-04-15 06:40:08 -04:00
John Ferlan
d92be7f42f storage: Use virStoragePoolSourceMatchSingleHost for NETFS
Rather than have duplicate code doing the same check, have the netfs
matching processing code use the new virStoragePoolSourceMatchSingleHost.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-04-15 06:40:07 -04:00
John Ferlan
401623bcb4 storage: Add check for different ports for host duplicate matching
In virStoragePoolSourceMatchSingleHost, add a comparison for port number
being different prior to checking the 'name' field.
2015-04-15 06:40:07 -04:00
John Ferlan
9aced8c9d5 storage: Create virStoragePoolSourceMatchSingleHost
Split out the nhost == 1 and hosts[0].name logic into a separate routine

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-04-15 06:40:07 -04:00
John Ferlan
fc20b41271 storage: Refactor iSCSI Source matching
Create a separate iSCSI Source matching subroutine. Makes the calling
code a bit cleaner as well as sets up for future patches which need to
do better source hosts[0].name processing/checking.

As part of the effort the logic will be inverted from a multi-level
if statement to a series of single level checks for better readability
and further separation

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-04-15 06:40:01 -04:00
Jiri Denemark
4864e377c9 sanlock: Use VIR_ERR_RESOURCE_BUSY if sanlock_acquire fails
When acquiring resource via sanlock fails, we would report it as
VIR_ERR_INTERNAL_ERROR, which is not very friendly to applications using
libvirt. Moreover, the lockd driver would report the same failure as
VIR_ERR_RESOURCE_BUSY, which looks better.

Unfortunately, in sanlock driver we don't really know if acquiring the
resource failed because it was already locked or there was another
reason behind. But the end result is the same and I think using
VIR_ERR_RESOURCE_BUSY reason for all acquire failures is still better
than what we have now.

https://bugzilla.redhat.com/show_bug.cgi?id=1165119
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-04-15 09:40:42 +02:00
Eric Blake
58dfc53414 build: provide virNetDevSysfsFile on non-Linux
Commit 49ed6cff is broken on mingw and other non-linux platforms:

  CCLD     libvirt.la
  Cannot export virNetDevSysfsFile: symbol not defined
  collect2: error: ld returned 1 exit status

* src/util/virnetdev.c: Provide virNetDevSysfsFile fallback.

Signed-off-by: Eric Blake <eblake@redhat.com>
2015-04-14 13:53:50 -06:00
Eric Blake
e4ab084813 build: include correct header for time()
Found by ./autobuild.sh during a mingw cross-compile:

Commit 8a96e87 was not innocuous - glibc happens to leak the
definition of time() through other headers, so that even without
<sys/select.h>, virrandom.c compiled just fine.  But on mingw,
we were not so lucky; <sys/select.h> was important for its side
effect of dragging in <time.h>, and we now have nothing providing
the declaration of time():

../../src/util/virrandom.c: In function 'virRandomOnceInit':
../../src/util/virrandom.c:65:5: error: implicit declaration of function 'time' [-Werror=implicit-function-declaration]
     unsigned int seed = time(NULL) ^ getpid();
          ^
	  ../../src/util/virrandom.c:65:5: error: nested extern declaration of 'time' [-Werror=nested-externs]

Signed-off-by: Eric Blake <eblake@redhat.com>
2015-04-14 13:24:51 -06:00
Michal Privoznik
49ed6cff99 Introduce virnetdevtest
This is yet another test for check of basic functionality of our
NIC state handling code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-14 19:33:02 +02:00
John Ferlan
ba7e88edf7 nwfilter: Change 'index' to 'idx'
Forthcoming syntax check rule will disallow usage of 'int index', so
change it for nwfilter
2015-04-14 11:18:28 -04:00
John Ferlan
29359e99bf snapshot: Change 'index' to 'idx'
Forthcoming syntax check rule will disallow usage of 'int index', so
change it for snapshot
2015-04-14 11:18:28 -04:00
John Ferlan
454e52c89d util: Use 'idx' instead of 'index'
Impending syntax checker will disallow 'int index', so change it here.
2015-04-14 11:18:28 -04:00
John Ferlan
f44429a0bc qemu: Adjust the prototype to match the function
Changing the prototype to not have "int *index" since we'll soon be
disallowing index as a name. Curiously the original commit (a4504ac)
for the function used 'int idx' in the function - so they didn't match.
Now they do.
2015-04-14 11:18:28 -04:00
Ján Tomko
682ba8e930 Add articles to virDomainDeviceDetachFlags docs
Reported by John Ferlan.
2015-04-14 15:32:24 +02:00
Pavel Hrdina
e60c84f0ce xen: fix build error on rhel-5
../../src/xen/block_stats.c:82: warning: dereferencing type-punned
    pointer will break strict-aliasing rules [-Wstrict-aliasing]

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-04-14 15:14:58 +02:00
Martin Kletzander
f38bd06bff sparc: Add default PCI root controller
It is there even with -nodefaults and -no-user-config, so count with
that so we can start sparc domains.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-04-14 14:49:15 +02:00
Huanle Han
a959671da8 hostdev: fix loop index error when resetvfnetconfig
The variable 'last_processed_hostdev_vf' indicates index of the last
successfully configed vf. When resetvfnetconfig because of failure,
hostdevs[last_processed_hostdev_vf] should also be reset.

Signed-off-by: Huanle Han <hanxueluo@gmail.com>
2015-04-14 14:49:15 +02:00
Huanle Han
c61ded8a7d qemu: fix index error when clean up vport profile
1. 'last_good_net' indicates the index of last successfully configured
net. so def->nets[last_good_net] should also be clean up if error occurs.

2. if error occurs in 'virNetDevMacVLanVPortProfileRegisterCallback'
(second 'goto err_exit' in loop), we should also do
'virNetDevVPortProfileDisassociate' cleanup for the
'virNetDevVPortProfileAssociate'(first code block in loop). So we should
consider the net is successfully configured after first code block in
loop finishes.

Signed-off-by: Huanle Han <hanxueluo@gmail.com>
2015-04-14 14:49:15 +02:00
Serge Hallyn
03d7462d87 virt-aa-helper: add unix channels (esp for qemu-guest-agent)
The original bug report was at
https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1393842

Also skip abstract unix sockets.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2015-04-14 14:06:27 +02:00
Shanzhi Yu
1db6212331 qemu: save domain status after set memory parameters
After set memory parameters for running domain, save the change to live
xml is needed otherwise it will disappear after restart libvirtd.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1211548
Signed-off-by: Shanzhi Yu <shyu@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2015-04-14 13:50:08 +02:00
John Ferlan
d375368790 qemu: Use 'idx' instead of 'index' for variable name
Apparently for Xen-devel 'index' is a global and causes a build failure,
so just use the shortened 'idx' instead to avoid the conflict.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-04-14 07:18:32 -04:00
Peter Krempa
634285f9c1 qemu: Refactor qemuDomainBlockJobAbort()
Change few variable names and refactor the code flow. As an additional
bonus the function now fails if the event state is not as expected.
2015-04-14 10:00:56 +02:00
Peter Krempa
8a609afb6f qemu: drivePivot: Fix assumption when 'block-job-complete' fails
QEMU does not abandon the mirror. The job carries on in the synchronised
phase and it might be either pivoted again or cancelled. The commit
hints that the described behavior was happening in a downstream version.

If the command returns false there are two possible options:
1) qemu did not reach the point where it would ask the block job to
pivot
2) pivotting failed in the actual qemu coroutine

If either of those would happen we return failure and reset the
condition that waits for the block job to complete. This makes the API
fail but in case where qemu would actually abandon the mirror the fact
is notified via the event and handled asynchronously.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1202704
2015-04-14 10:00:56 +02:00
Peter Krempa
065a81082d qemu: blockPull: Refactor the rest of qemuDomainBlockJobImpl
Since it now handles only block pull code paths we can refactor it and
remove tons of cruft.
2015-04-14 10:00:56 +02:00
Peter Krempa
cfc0a3d4ce qemu: blockjob: Separate qemuDomainBlockJobAbort from qemuDomainBlockJobImpl
Sacrifice a few lines of code in favor of the code being more readable.
2015-04-14 10:00:56 +02:00
Peter Krempa
1344a74ef2 qemu: blockjob: Split qemuDomainBlockJobSetSpeed from qemuDomainBlockJobImpl
qemuDomainBlockJobImpl become an unmaintainable mess over the years of
adding new stuff to it. This patch starts splitting up individual
functions from it until it can be killed entirely.

In bulk this will add lines of code rather than delete them but it will
be traded for maintainability.
2015-04-14 10:00:56 +02:00
Peter Krempa
7db64d6b0a qemu: monitor: Extract handling of JSON block job error codes
My intention is to split qemuMonitorJSONBlockJob() into simpler separate
functions for every block job type. Since the error handling code is the
same for all block jobs, this patch extracts the code into a separate
function that will later be reused in more places.

With the new helper qemuMonitorJSONErrorIsClass we can save a few
function calls as we can extract the error object once.
2015-04-14 10:00:56 +02:00
Peter Krempa
72613b18ac qemu: monitor: json: Refactor error code class checker
Split out the function that checks the actual error class string into a
separate helper as it will be useful later and refactor
qemuMonitorJSONHasError to return bool type and remove few useless
checks.

Basically virJSONValueObjectHasKey are useless here since the next call
to virJSONValueObjectGet is checking the return value again (which can't
fail at that point). By removing the first check we save a function
call.
2015-04-14 10:00:56 +02:00
Peter Krempa
64985217bc qemu: Fix condition for checking vcpu when pinning vcpus
Previously we checked that the vcpu we are trying to set is in range of
the number of threads presented by qemu. The problem is that if the VM
is offline the count is 0. Since the condition subtracted 1 from the
count the number would overflow and the check would never trigger.

Change the condition for more sensible ones with specific error
messages.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1208434
2015-04-14 09:31:48 +02:00
Peter Krempa
3f9fb2b587 conf: Refactor virDomainVcpuPinDefParseXML
Refactor the code to parse the vcpupin in a similar way the iothreadpin
code is now structured. This allows to get rid of some very strange
conditions and error messages.

Additionally since a existing bug
( https://bugzilla.redhat.com/show_bug.cgi?id=1208434 ) allows to add
vcpupin definitions for vcpus that don't exist, this patch makes the
parser to ignore all vcpupins that don't have a matching vCPU in the
definition rather than just offlined ones.
2015-04-14 09:28:02 +02:00
Peter Krempa
78d1b0f9b3 conf: Error out if iothread id is missing in iothreadpin
Defining a domain with the following config:

<domain ...>
  ...
  <iothreads>1</iothreads>
  <cputune>
    <iothreadpin cpuset='1'/>

will result in the following config formatted back:
<domain type='kvm'>
  ...
  <iothreads>1</iothreads>
  <cputune>
    <iothreadpin iothread='0' cpuset='1'/>

After restart the VM would vanish. Since our schema requires the
@iothread field to be present in <iothreadpin> make it required by the
code too.
2015-04-14 09:23:23 +02:00
Peter Krempa
0532ec3faa conf: Split up virDomainVcpuPinDefParseXML
Extract part that parses iothreads into virDomainIothreadPinDefParseXML
2015-04-14 09:23:13 +02:00
Peter Krempa
06c03b48bd conf: Split out parsing of emulatorpin
Split up parts of virDomainVcpuPinDefParseXML into
virDomainEmulatorPinDefParseXML.
2015-04-14 09:13:26 +02:00
Peter Krempa
d56707766e lib: snapshot: Explain that only one layer of images is inserted
When creating a snapshot with _REUSE_EXTERNAL when the pre-created image
does not directly link to the current active layer libvirt would
re-detect the backing chain incorrectly and it would not match with
qemu's view. Since the configuration is an operator mistake, document
that only the top layer image gets inserted.
2015-04-14 08:59:12 +02:00
Peter Krempa
714b38cb23 qemu: Enforce WWN to be unique among VM's disks
Operating systems use the identifier to name the disks. As the name
suggests the ID should be unique.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1208009
2015-04-14 08:44:36 +02:00
Peter Krempa
c35b011087 conf: ABI: Check WWN in disk abi stability check
Since the WWN influences guest behavior in naming disks we should treat
this as vm ABI.
2015-04-14 08:44:36 +02:00
John Ferlan
9e4d7b48f8 Convert virDomainPinIsDuplicate into bool return
Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-04-13 18:02:02 -04:00
John Ferlan
2bcc263338 Rename qemuCheckIothreads to qemuCheckIOThreads
Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-04-13 17:26:37 -04:00
Alexander Burluka
1e715a8d08 Parallels: implemented domainAttachDevice
That function uses domainAttachDeviceFlags

Signed-off-by: Alexander Burluka <aburluka@parallels.com>
2015-04-13 17:56:13 +03:00
Alexander Burluka
fcba57b2ec Parallels: implement domainAttachDeviceFlags
Parallels Cloud Server supports block devices and virtual NIC
live attachment. I implemented that function for block devices so
OpenStack volume attachment is now works.

Signed-off-by: Alexander Burluka <aburluka@parallels.com>
2015-04-13 17:55:27 +03:00
Alexander Burluka
92b54f1c4a Parallels: remove disk serial number check
OpenStack needs disk serial number setup because
nova boot --block-device-mapping command generates that param in
libvirt xml. I took QEMU libvirt driver behavior as a base.
QEMU driver skips inability to set serial and continues work.
So Parallels driver will ignore this param too and let domain
boot.
2015-04-13 17:23:13 +03:00
Ján Tomko
9146fd7aa9 Remove overengineered loop
Do not loop over enum with one value.
2015-04-13 15:59:20 +02:00
Ján Tomko
fbcf7da95b Introduce struct _virStorageBackendQemuImgInfo
This will contain the data required for creating the qemu-img
command line without having access to the volume definition.
2015-04-13 15:59:20 +02:00
Ján Tomko
a832735df9 Rename virStorageBackendCreateQemuImgCmd
Add FromVol at the end. This function will create the qemu-img
command line from volume definitions and check them.
2015-04-13 15:59:20 +02:00
Ján Tomko
c59304e7e8 Use XPath when parsing snapshot disk definition
Instead of going through XML nodes in a loop and
having to check if they are duplicate.
2015-04-13 15:07:45 +02:00
Ján Tomko
9b90899915 Split out storage format 'compat' attribute sanity check
For future reuse in the snapshot XML.
2015-04-13 15:07:45 +02:00
Erik Skultety
b77ce18a28 virBitmap: Place virBitmapIsAllClear check after virBitmapParse calls
This patch adds checks for empty bitmaps right after the calls of
virBitmapParse. These only include spots where set API's are called and
where domain's XML is parsed.
Also, it partially reverts commit 983f5a which added a check for
invalid nodeset "0,^0" into virBitmapParse function. This change broke
the logic, as an empty bitmap should not cause an error.

https://bugzilla.redhat.com/show_bug.cgi?id=1210545
2015-04-13 14:21:02 +02:00
Ján Tomko
6cb9f5046f Remove feature formating funcs from pool-specific options
We only have one formatting function for the features.
2015-04-13 14:05:29 +02:00
Ján Tomko
55a0670a6d Rewrite usb device version parsing
Simplify the function by leaving out the local copy and checking
return values of virStrToLong.
2015-04-13 12:42:02 +02:00
Ján Tomko
a75069be35 Fix usb device version parsing issues
Request that the number be parsed as decimal, to allow 08
and 09.

Format it with the leading zero, 1.01 and 1.10 are two
different versions.

https://bugzilla.redhat.com/show_bug.cgi?id=1210650
2015-04-13 12:33:41 +02:00
Ján Tomko
74b45e586e Do not require virtio-pci devices when using virtio-mmio
On arm, we probe for virtio-*-pci devices, but use their
virtio-*-device variants.

Set the capabilities based on the -device variants as well,
to make them work with qemus with the PCI devices compiled out.
2015-04-13 12:23:13 +02:00
Michal Privoznik
65a88572ad qemuMigrationPrecreateStorage: Fix debug message
When pre-creating storage for domains, we need to find corresponding
disk in the XML on the destination (domain XML may differ there, e.g.
disk is accessible under different path). For better debugging, I'm
printing all info I received on a disk. But there was a typo when
printing the disk capacity: "%lluu" instead of "%llu".

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-13 11:40:57 +02:00
Xing Lin
522e81cbb5 qemu_migration.c: sleep first before checking for migration status.
The problem with the previous implementation is,
even when qemuMigrationUpdateJobStatus() detects a migration job
has completed, it will do a sleep for 50 ms (which is unnecessary
and only adds up to the VM pause time).

Signed-off-by: Xing Lin <xinglin@cs.utah.edu>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-13 09:52:28 +02:00
Andrea Bolognani
e4d7ddfdd2 conf: Don't output <cpu> tag if it contains no information.
The tag is already marked as optional in the schema, so no changes
are needed there.

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1202606
2015-04-13 09:27:26 +02:00
John Ferlan
b487bb810e qemu: qemuDomainHotplugVcpus - separate out pin adjustment code
Future IOThread setting patches would copy the code anyway, so create
and generalize the adding of pindef for the vcpu and the pinning of the
thread into their own APIs.
2015-04-10 16:02:40 -04:00
Ján Tomko
031323830d Support IPv6 in networkGetNetworkAddress
We've been explicitly requesting IPv4 for some reason,
even if there were only IPv6 addresses in the network
definition.

https://bugzilla.redhat.com/show_bug.cgi?id=1192318
2015-04-10 15:01:17 +02:00
Luyao Huang
2605089c04 util: Update virNetDevGetIPAddress to get IPv6 addresses
Add static virNetDevGetifaddrsAddress to attempt to get the interface
IP address. If getifaddrs is not supported, fall back to
virNetDevGetIPv4AddressIoctl to get the IP address.

This allows IPv6 addresses to be used for <listen type='network>
with device-backed networks.

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

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2015-04-10 15:01:17 +02:00
John Ferlan
61fee39967 util: Replace virNetDevGetIPv4Address with virNetDevGetIPAddress
Rename it to virNetDevGetIPv4AddressIoctl and make
virNetDevGetIPAddress a wrapper around it, allowing
other ways of getting the address to be implemented,
and still falling back to the old method.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2015-04-10 15:01:17 +02:00
Dmitry Guryanov
2027045f8a parallels: fix virDomainDefineXML for domain in saved state
PCS doesn't store domain config in managed save state file.
It's forbidden to change config for VMs in this state.
It's possible to change config for containers, but after
restoring domain will have that new config, not a config,
which domain had at the moment of virDomainManagedSave.

So we need to handle this case differently from other states.
Let's forbid this operation, if config is changed and if it's
not changed - just do nothing.

Openstack/nova calls virDomainDefineXML on resume with
current domain config, so we can't forbid this operation
in managed save state.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2015-04-10 13:39:35 +02:00
Dmitry Guryanov
ffb52467a2 conf: fix virDomainDefFormatInternal for parallels
We should add input devices with proper bus,
not VIR_DOMAIN_INPUT_BUS_XEN.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-10 13:39:29 +02:00
Dmitry Guryanov
79847f73c3 conf: fix virDomainDefParseXML for parallels
Handle input devices in virDomainDefParseXML properly
in case of parallels containers and VMs.

Parallels containers support only
VIR_DOMAIN_INPUT_BUS_PARALLELS. And if VNC is enabled
we should add implicit mouse and keyboard.

For VMs we should add implicit PS/2 mouse and
keyboard.

BTW, is it worth to refactor code and move
all this code to drivers, to *DomainDefPostParse
functions?

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-10 13:31:49 +02:00
Dmitry Guryanov
c0c3d4c8c9 parallels: add implicit input devices
Add implicit input devices in parallelsLoadDomains,
when VNC is enabled.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2015-04-10 09:50:30 +02:00
Dmitry Guryanov
6cc2cdf62f conf: add input device type for parallels containers
Add VIR_DOMAIN_INPUT_BUS_PARALLELS device type
to handle domain configuration properly for
parallels containers, when VNC is enabled.

When domain configuration has at least one
'graphics', there should be mouse and keyboard.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2015-04-10 09:50:30 +02:00
Dmitry Guryanov
756f8dcd40 conf: return proper default video type for parallels
Fix function virDomainVideoDefaultType for
parallels VMs and containers. It should return
VGA for VMs and VIR_DOMAIN_VIDEO_TYPE_PARALLELS
for containers.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2015-04-10 09:50:30 +02:00
Dmitry Guryanov
0d572b6982 conf: add VIR_DOMAIN_VIDEO_TYPE_PARALLELS video type
We support VNC for containers to have the same
interface with VMs. At this moment it just renders
linux text console.

Of course we don't pass any physical devices and
don't emulate virtual devices. Our VNC server
renders text from terminal master and sends
input events from VNC client to terminal.

So add special video type VIR_DOMAIN_VIDEO_TYPE_PARALLELS
for these pseudo-devices.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2015-04-10 09:50:29 +02:00
Dmitry Guryanov
b16868a135 parallels: don't fill net adapter model for containers
Network adapter model has no sense for container,
so we shouldn't set it to e1000 in
parallelsDomainDeviceDefPostParse.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2015-04-10 09:50:29 +02:00
Dmitry Guryanov
6a06b467f5 parallels: fill adapter model in virDomainNetDef
We handle this parameter for VMs while defining
domains, so let's get this property from PCS and
set corresponding field of virDomainNetDef in
prlsdkLoadDomains function.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2015-04-10 09:50:29 +02:00
Dmitry Guryanov
b204afa13e parallels: add controllers in prlsdkLoadDomain
Call virDomainDefAddImplicitControllers to add disk
controllers, so virDomainDef, filled by this function
will look exactly like the one returned by virDomainDefParseString.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2015-04-10 09:50:29 +02:00
Dmitry Guryanov
66aee37530 parallels: report, that cdroms are readonly
Set readonly flag for cdrom devices when we
retrieve a list of domains from PCS.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2015-04-10 09:50:29 +02:00
Dmitry Guryanov
8951ad86ce parallels: implement virDomainManagedSave
Implement virDomainManagedSave api function. In PCS
this feature called "suspend". You can suspend VM or
CT while it is in running or paused state. And after
resuming (or starting) it will have the same state, as
before suspend.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2015-04-10 09:50:29 +02:00
Dmitry Guryanov
233b799ddb parallels: split prlsdkDomainChangeState function
Split function prlsdkDomainChangeState into
prlsdkDomainChangeStateLocked and prlsdkDomainChangeState.
So it can be used from places, where virDomainObj already
found and locked.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2015-04-10 09:50:29 +02:00
Dmitry Guryanov
18558ae80f parallels: fix headers in parallels_sdk.h
Return value of functions prlsdkStart/Kill/Stop e.t.c.
is PRL_RESULT in parallels_sdk.c and int in parallels_sdk.h.
PRL_RESULT is int, so compiler didn't report errors.
Let's fix the difference.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2015-04-10 09:50:29 +02:00
John Ferlan
97a1d94fa0 qemu: qemuDomainHotplugVcpus - separate out the del cgroup and pin
Future IOThread setting patches would copy the code anyway, so create
and generalize a delete cgroup and pindef for the vcpu into its own API.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-04-09 19:27:08 -04:00
John Ferlan
0ed8e47a7e qemu: qemuDomainHotplugVcpus - separate out the add cgroup
Future IOThread setting patches would copy the code anyway, so create
and generalize the add the vcpu to a cgroup into its own API.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-04-09 19:27:08 -04:00
John Ferlan
0456eda317 cgroup: Use virCgroupNewThread
Replace the virCgroupNew{Vcpu|Emulator|IOThread} calls with the common
virCgroupNewThread API

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-04-09 19:27:08 -04:00
John Ferlan
2cd3a980dc cgroup: Introduce virCgroupNewThread
Create a new common API to replace the virCgroupNew{Vcpu|Emulator|IOThread}
API's using an emum to generate the cgroup name

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-04-09 19:27:08 -04:00
John Ferlan
2ac0e647bd storage: Don't duplicate efforts of backend driver
https://bugzilla.redhat.com/show_bug.cgi?id=1206521

If the backend driver updates the pool available and/or allocation values,
then the storage_driver VolCreateXML, VolCreateXMLFrom, and VolDelete APIs
should not change the value; otherwise, it will appear as if the values
were "doubled" for each change.  Additionally since unsigned arithmetic will
be used depending on the size and operation, either or both values could be
appear to be much larger than they should be (in the EiB range).

Currently only the disk pool updates the values, but other pools could.
Assume a "fresh" disk pool of 500 MiB using /dev/sde:

$ virsh pool-info disk-pool
...
Capacity:       509.88 MiB
Allocation:     0.00 B
Available:      509.84 MiB

$ virsh vol-create-as disk-pool sde1 --capacity 300M

$ virsh pool-info disk-pool
...
Capacity:       509.88 MiB
Allocation:     600.47 MiB
Available:      16.00 EiB

Following assumes disk backend updated to refresh the disk pool at deletion
of primary partition as well as extended partition:

$ virsh vol-delete --pool disk-pool sde1
Vol sde1 deleted

$ virsh pool-info disk-pool
...
Capacity:       509.88 MiB
Allocation:     9.73 EiB
Available:      6.27 EiB

This patch will check if the backend updated the pool values and honor that
update.
2015-04-09 19:04:18 -04:00
John Ferlan
1ffd82bb89 storage: Need to update freeExtent at delete primary partition
Commit id '471e1c4e' only considered updating the pool if the extended
partition was removed. As it turns out removing a primary partition
would also need to update the freeExtent list otherwise the following
sequence would fail (assuming a "fresh" disk pool for /dev/sde of 500M):

$  virsh pool-info disk-pool
...
Capacity:       509.88 MiB
Allocation:     0.00 B
Available:      509.84 MiB

$ virsh vol-create-as disk-pool sde1 --capacity 300M
$ virsh vol-delete --pool disk-pool sde1
$ virsh vol-create-as disk-pool sde1 --capacity 300M
error: Failed to create vol sde1
error: internal error: no large enough free extent

$

This patch will refresh the pool, rereading the partitions, and
return
2015-04-09 19:04:18 -04:00
John Ferlan
1095230dee storage: Fix issues in storageVolResize
https://bugzilla.redhat.com/show_bug.cgi?id=1073305

When creating a volume in a pool, the creation allows the 'capacity'
value to be larger than the available space in the pool. As long as
the 'allocation' value will fit in the space, the volume will be created.

However, resizing the volume checks were made with the new absolute
capacity value against existing capacity + the available space without
regard for whether the new absolute capacity was actually allocating
space or not.  For example, a pool with 75G of available space creates
a volume of 10G using a capacity of 100G and allocation of 10G will succeed;
however, if the allocation used a capacity of 10G instead and then tried
to resize the allocation to 100G the code would fail to allow the backend
to try the resize.

Furthermore, when updating the pool "available" and "allocation" values,
the resize code would just "blindly" adjust them regardless of whether
space was "allocated" or just "capacity" was being adjusted.  This left
a scenario whereby a resize to 100G would fail; however, a resize to 50G
followed by one to 100G would both succeed.  Again, neither was adjusting
the allocation value, just the "capacity" value.

This patch adds more logic to the resize code to understand whether the
new capacity value is actually "allocating" space as well and whether it
shrinking or expanding. Since unsigned arithmatic is involved, the possibility
that we adjust the pool size values incorrectly is probable.

This patch also ensures that updates to the pool values only occur if we
actually performed the allocation.

NB: The storageVolDelete, storageVolCreateXML, and storageVolCreateXMLFrom
each only updates the pool allocation/availability values by the target
volume allocation value.
2015-04-09 19:04:18 -04:00
Peter Krempa
a45ef3a9cd qemu: Avoid shadow of 'sync' symbol
Old compilers whine that 'sync' is being shadowed in the function
introduced in 1eccac1d2d.
2015-04-09 15:36:26 +02:00
Peter Krempa
7c62f239f4 qemu: blockPivot: Don't pause the VM any more since we don't use drive-reopen
Support for drive-reopen was never present in the upstream code so we
don't need to pause the VM when doing the block pivot. Kill all the
code related to this semi-upstream artifact.
2015-04-09 15:04:30 +02:00
Peter Krempa
db37f3cc3a qemu: Clean up old leftovers in qemuMonitorDrivePivot
There are two leftover unused variables. Remove them and clean up the
fallout of the change.
2015-04-09 14:18:48 +02:00
Peter Krempa
3eab2f647a qemu: blockjob: Use the new helpers in qemuDomainGetBlockJobInfo
Refactor the function to use the new helpers.
2015-04-09 14:11:49 +02:00
Peter Krempa
1eccac1d2d qemu: domain: Add helper to check block job support
We need to check that qemu supports block jobs in multiple places. Add a
helper to do the check.
2015-04-09 14:11:42 +02:00
Peter Krempa
88dc7e0c2f qemu: domain: Introduce helper to retrieve domain monitor object
In some cases where the function does not need to access the private
data this helper may be used to retrieve the monitor object.
2015-04-09 14:11:36 +02:00
Cédric Bosdonnat
cc21badc5c Open /proc/PID/ns/* read-only to avoid getting permission denied
lxc-enter-namespace stopped working on recent kernels (at least 3.19+)
due to /proc/PID/ns/* file descriptors being opened RW. From outside
the namespace these can only be opened RO.
2015-04-09 11:20:32 +02:00
Lubomir Rintel
da33a1ac1f lxc: create the required directories upon driver start
/var/run may reside on a tmpfs and we fail to create the PID file if
/var/run/lxc does not exist.

Since commit 0a8addc1, the lxc driver's state directory isn't
automatically created before starting a domain. Now, the lxc driver
makes sure the state directory exists when it initializes.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
2015-04-09 11:06:26 +02:00
Peter Krempa
fac04598bb util: file: Don't carelessly sanitize URIs
rfc3986 states that the separator in URI path is a single slash.
Multiple slashes may potentially lead to different resources and thus we
should not remove them.
2015-04-09 09:43:36 +02:00
Michal Privoznik
362566880f virLXCControllerSetupResourceLimits: Call virNuma*() iff needed
Like we are doing in qemu driver (ea576ee543), lets call
virNumaSetupMemoryPolicy() only if really needed. Problem is, if
we numa_set_membind() child, there's no way to change it from the
daemon afterwards. So any later attempts to change the pinning
will fail. But in very weird way - CGroups will be set, but due
to membind child will not allocate memory from any other node.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-08 12:01:10 +02:00
Luyao Huang
7cd0cf05f7 fix memleak in qemuRestoreCgroupState
131,088 bytes in 16 blocks are definitely lost in loss record 2,174 of 2,176
    at 0x4C29BFD: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
    by 0x4C2BACB: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
    by 0x52A026F: virReallocN (viralloc.c:245)
    by 0x52BFCB5: saferead_lim (virfile.c:1268)
    by 0x52C00EF: virFileReadLimFD (virfile.c:1328)
    by 0x52C019A: virFileReadAll (virfile.c:1351)
    by 0x52A5D4F: virCgroupGetValueStr (vircgroup.c:763)
    by 0x1DDA0DA3: qemuRestoreCgroupState (qemu_cgroup.c:805)
    by 0x1DDA0DA3: qemuConnectCgroup (qemu_cgroup.c:857)
    by 0x1DDB7BA1: qemuProcessReconnect (qemu_process.c:3694)
    by 0x52FD171: virThreadHelper (virthread.c:206)
    by 0x82B8DF4: start_thread (pthread_create.c:308)
    by 0x85C31AC: clone (clone.S:113)

Signed-off-by: Luyao Huang <lhuang@redhat.com>
2015-04-08 11:56:30 +02:00