Commit Graph

181 Commits

Author SHA1 Message Date
Michal Privoznik
53cae19561 conf: s/virNetworkFindByName/virNetworkObjFindByName/
It's returning virNetworkObjPtr after all. And it matches the
pattern laid out by domain_conf.h.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-04 10:12:16 +01:00
Michal Privoznik
82f240ae56 conf: s/virNetworkFindByUUID/virNetworkObjFindByUUID/
It's returning virNetworkObjPtr after all. And it matches the
pattern laid out by domain_conf.h.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-04 10:11:40 +01:00
Michal Privoznik
c3dfec15ae parallels: s/virNetworkObjList/virNetworkObjListPtr/
In order to hide the object internals (and use just accessors
everywhere), lets store a pointer to the object, instead of object
itself.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-04 10:10:50 +01:00
Michal Privoznik
bbbc7e41e0 virNetworkObjListExport: Pass virNetworkObjListPtr
Instead of copying the whole object onto stack when calling the
function, just pass the pointer to the object and save up some
space on the stack. Moreover, this prepares the code to hide the
virNetworkObjList structure into network_conf.c and use accessors
only.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-03-04 10:09:30 +01:00
Ján Tomko
cbd788eba6 Add flags argument to virStorageVolDefParse*
Allow the callers to pass down libvirt-internal flags.
2015-03-02 08:07:11 +01:00
Yuri Chornoivan
8a833d1eb0 Fix typos in messages
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2015-02-25 14:12:51 +01:00
Peter Krempa
c03411199e conf: Allocate domain definition with the new helper
Use the virDomainDefNew() helper to allocate the definition instead of
doing it via VIR_ALLOC.
2015-02-20 17:43:05 +01:00
Peter Krempa
6bc80fa86d conf: numa: Rename virDomainNumatune to virDomainNuma
The structure will gradually become the only place for NUMA related
config, thus rename it appropriately.
2015-02-20 17:43:04 +01:00
Mikhail Feoktistov
675fa6b360 parallels: Set the first HDD from XML as bootable
1. Delete all boot devices for VM instance
2. Find the first HDD from XML and set it as bootable

Now we support only one boot device and it should be HDD.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-02-19 16:32:49 +01:00
Mikhail Feoktistov
6783cf63b0 parallels: Use IS_CT() macro instead of STREQ("exe") 2015-02-19 16:32:49 +01:00
Mikhail Feoktistov
0268eabd7d parallels: code aligment 2015-02-19 16:32:49 +01:00
Ján Tomko
481881f50a Trivially support DomainHasManagedSaveImage
Return 0 instead of ERR_NO_SUPPORT in each driver
where we don't support managed save or -1 if
the domain does not exist.

This avoids spamming daemon logs when 'virsh dominfo' is run.

https://bugzilla.redhat.com/show_bug.cgi?id=1095637
2015-02-06 12:52:50 +01:00
Daniel P. Berrange
55ea7be7d9 Removing probing of secondary drivers
For stateless, client side drivers, it is never correct to
probe for secondary drivers. It is only ever appropriate to
use the secondary driver that is associated with the
hypervisor in question. As a result the ESX & HyperV drivers
have both been forced to do hacks where they register no-op
drivers for the ones they don't implement.

For stateful, server side drivers, we always just want to
use the same built-in shared driver. The exception is
virtualbox which is really a stateless driver and so wants
to use its own server side secondary drivers. To deal with
this virtualbox has to be built as 3 separate loadable
modules to allow registration to work in the right order.

This can all be simplified by introducing a new struct
recording the precise set of secondary drivers each
hypervisor driver wants

struct _virConnectDriver {
    virHypervisorDriverPtr hypervisorDriver;
    virInterfaceDriverPtr interfaceDriver;
    virNetworkDriverPtr networkDriver;
    virNodeDeviceDriverPtr nodeDeviceDriver;
    virNWFilterDriverPtr nwfilterDriver;
    virSecretDriverPtr secretDriver;
    virStorageDriverPtr storageDriver;
};

Instead of registering the hypervisor driver, we now
just register a virConnectDriver instead. This allows
us to remove all probing of secondary drivers. Once we
have chosen the primary driver, we immediately know the
correct secondary drivers to use.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2015-01-27 12:02:04 +00:00
Dmitry Guryanov
2bc460d3c1 parallels: create container from existing image
It's possible to create a container with existing
disk image as root filesystem. You need to remove
existing disks from PCS VM config and then add a new
one, pointing to your image. And then call PrlVm_RegEx
with PRNVM_PRESERVE_DISK flag.

With this patch you can create such container with
something like this for new domain XML config:

    <filesystem type='file' accessmode='passthrough'>
      <driver type='ploop' format='ploop'/>
      <source file='/path-to-image'/>
      <target dir='/'/>
    </filesystem>

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-01-16 14:07:47 +01:00
Dmitry Guryanov
aba95c287c parallels: allow to add filesystems to container
Handle information about filesystems in domain config
and add corresponding devices to container via
parallels sdk.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2015-01-16 14:07:47 +01:00
Dmitry Guryanov
d86f2aa336 parallels: commit with PVCF_DETACH_HDD_BUNDLE flag
PCS removes disk image from filesystem, if you remove it
from config. There is a special flag PVCF_DETACH_HDD_BUNDLE
which allow to remove disk only from VM/CT config.

If you call virDomainDefine and remove some disk from
config it should be preserved, so call PrlVm_CommitEx
always with flag PVCF_DETACH_HDD_BUNDLE.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2015-01-16 14:07:47 +01:00
Dmitry Guryanov
4bbd3b1e7e parallels: dump info about container filesystems
Obtain information about container's filesystems and
store it in virDomainDef structure.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-01-16 14:07:47 +01:00
Daniel P. Berrange
dd69a14f90 Add support for schema validation when passing in XML
The virDomainDefineXMLFlags and virDomainCreateXML APIs both
gain new flags allowing them to be told to validate XML.
This updates all the drivers to turn on validation in the
XML parser when the flags are set
2015-01-15 16:40:27 +00:00
Daniel P. Berrange
0ecd685109 Give virDomainDef parser & formatter their own flags
The virDomainDefParse* and virDomainDefFormat* methods both
accept the VIR_DOMAIN_XML_* flags defined in the public API,
along with a set of other VIR_DOMAIN_XML_INTERNAL_* flags
defined in domain_conf.c.

This is seriously confusing & error prone for a number of
reasons:

 - VIR_DOMAIN_XML_SECURE, VIR_DOMAIN_XML_MIGRATABLE and
   VIR_DOMAIN_XML_UPDATE_CPU are only relevant for the
   formatting operation
 - Some of the VIR_DOMAIN_XML_INTERNAL_* flags only apply
   to parse or to format, but not both.

This patch cleanly separates out the flags. There are two
distint VIR_DOMAIN_DEF_PARSE_* and VIR_DOMAIN_DEF_FORMAT_*
flags that are used by the corresponding methods. The
VIR_DOMAIN_XML_* flags received via public API calls must
be converted to the VIR_DOMAIN_DEF_FORMAT_* flags where
needed.

The various calls to virDomainDefParse which hardcoded the
use of the VIR_DOMAIN_XML_INACTIVE flag change to use the
VIR_DOMAIN_DEF_PARSE_INACTIVE flag.
2015-01-13 16:26:12 +00:00
Daniel P. Berrange
ee043216e6 parallels: don't override error message when XML parsing fails
The virDomainDefParseString method will report a suitable error
on parsing fail, so don't replace that.
2015-01-13 10:43:07 +00:00
Daniel P. Berrange
4d2ebc71ce Add stub virDomainDefineXMLFlags impls
Make sure every virt driver implements virDomainDefineXMLFlags
by adding a trivial passthrough from the existing impl with
no flags set.
2015-01-13 10:38:56 +00:00
Alexander Burluka
95170a3085 Parallels: Add VNC hostname setup
Add missing VNC setup via Parallels SDK.
Parallels Cloud Server starts one VNC server per domain,
so we could process only one VNC server definition.
Network-based listening currently is unimplemented.

Signed-off-by: Alexander Burluka <aburluka@parallels.com>
2015-01-07 09:58:18 +01:00
Dmitry Guryanov
7c6dbf3518 parallels: report, that cdrom image is raw
VIR_STORAGE_FILE_AUTO should be used only in xml provided to
libvirt by user, if I understood correctly. Driver should
set storage source format to specific disk format in
*DomainGetXMLDesc.

CDROMs in PCS use raw image format.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2014-12-23 15:13:13 +01:00
Dmitry Guryanov
dec21593e1 parallels: fix usage of disk->info.addr.drive structure
For SCSI and SATA devices controller and unit are used
to specify drive address. For IDE devices - bus specifies
IDE bus, becase usually there are 2 IDE buses on IDE
controller.

Parallels SDK allows to set drive position by calling
PrlVmDev_SetStackIndex. Since PCS VMs have only one
controller of each type, for SATA and SCSI devices it
simple means position on bus, for IDE devices -
2 * bus_number + position_on_bus.

This patch fixes mapping from libvirt's disk->info.addr.drive
to parallels's 'StackIndex'.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2014-12-15 17:20:45 +01:00
Dmitry Guryanov
87be10858f parallels: set format for real disk devices
It seems file format is usually specified event for
real block devices. So report that file format is
raw in virDomainGetXMLDesc and add checks for proper
file format to prlsdkAddDisk.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2014-12-15 17:20:44 +01:00
Dmitry Guryanov
6cfeef1751 parallels: support NULL virDomainVideoAccelDefPtr
NULL value of virDomainVideoAccelDefPtr means default
values for video acceleration, so don't report error in
this case.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2014-12-15 17:20:44 +01:00
Dmitry Guryanov
ab8715506f parallels: report proper error in Create/Destroy/Suspend e.t.c.
If we want to perform some operation and domain state is not suitable
for that operation, we should report error VIR_ERR_OPERATION_INVALID.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2014-12-09 19:42:04 +01:00
Dmitry Guryanov
b56c07a6a1 parallels: fix getJobResultHelper
When PrlJob_GetRetCode sets second argument to
error value it means sdk function failed and we
must return error from getJobResultHelper.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2014-12-09 19:42:04 +01:00
Dmitry Guryanov
1679883a45 parallels: return PRL_RESULT from waitJob and getJobResult
Return error code, returned by parallels SDK from
waitJob and getJobResult, so that caller can handle
different errors.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2014-12-09 19:42:04 +01:00
Dmitry Guryanov
7cbb50e912 parallels: implement domainUndefine and domainUndefineFlags
Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2014-12-09 19:42:04 +01:00
Dmitry Guryanov
a7ed488dd7 parallels: add cdroms support
Get cdrom devices list from parallels server in
prlsdkLoadDomains and add ability to define a domain
with cdroms.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2014-12-09 19:42:04 +01:00
Alexander Burluka
038a5a536b parallels: Add domainCreateWithFlags() function.
domainCreateWithFlags function is used by OpenStack/Nova to boot
an instance.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2014-12-09 19:42:04 +01:00
Alexander Burluka
6f67d9c0cf parallels: added function virDomainIsActive()
That function is necessary for proper domain removal
in openstack/nova.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2014-12-09 19:42:04 +01:00
Dmitry Guryanov
54a60fd70e parallels: refactor parallelsDomainDefineXML
First, we don't need to call prlsdkApplyConfig after
creating new VM or containers, because it's done in
functions prlsdkCreateVm and prlsdkCreateCt.

No need to check, if domain exists in the list after
prlsdkAddDomain.

Also organize code, so that we can call virObjectUnlock
in one place.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2014-12-09 19:42:04 +01:00
Dmitry Guryanov
66d89199b4 parallels: create VMs and containers with sdk
This patch replaces code, which creates domains by
running prlctl command.

prlsdkCreateVm/Ct will do prlsdkApplyConfig, because
we send request to the server only once in this case.

But prlsdkApplyConfig will be called also from
parallelsDomainDefineXML function. There is no problem with
it, parallelsDomainDefineXML will be refactored later.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2014-12-09 19:42:04 +01:00
Dmitry Guryanov
02954c0bd3 parallels: rewrite parallelsApplyConfig with SDK
Rewrite code, which applies domain configuration given
to virDomainDefineXML function to the VM of container
registered in PCS.

This code first check if there are unsupported parameters
in domain XML and if yes - reports error. Some of such
parameters are not supported by PCS, for some - it's not
obvious, how to convert them into PCS's corresponding params,
so let's put off it, and implement only basic params in
this patch.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2014-12-09 19:42:04 +01:00
Dmitry Guryanov
560dcdf02f parallels: reimplement functions, which change domain state
Change domain state using parallels SDK functions instead of
prlctl command.

We don't need to send events from these functions now, becase
events handler will send them. But we still need to update
virDomainObj in privconn->domains.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2014-12-09 19:42:04 +01:00
Alexander Burluka
0a7aba408e parallels: handle events from parallels server
Subscribe to events from parallels server. It's
needed for 2 things: to update cached domains list
and to send corresponding libvirt events.

Parallels server sends a lot of different events, in
this patch we handle only some of them. In the future
we can handle for example, changes in a host network
configuration or devices states.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2014-12-09 19:42:04 +01:00
Dmitry Guryanov
8dec6bbbfe parallels: move parallelsDomNotFoundError to parallels_utils.h
Move macro parallelsDomNotFoundError to file parallels_utils.h, because
it will be used in parallels_sdk.c.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2014-12-09 19:42:04 +01:00
Alexander Burluka
7039bb3cd1 parallels: get domain info with SDK
Obtain information about domains using parallels sdk instead of prlctl.
prlsdkLoadDomains functions behaves as former parallelsLoadDomains with
NULL as second parameter (name) - it fills parallelsConn.domains list.

prlsdkLoadDomain is now able to update specified domain by given
virDomainObjPtr.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2014-12-09 19:42:04 +01:00
Dmitry Guryanov
d211ba7c49 parallels: move IS_CT macro to parallels_utils.h
This macro will be used in paralles_sdk.c so move it to common header.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2014-12-09 19:42:03 +01:00
Dmitry Guryanov
572d050895 parallels: fix compilation of parallels_storage.c
virConnect.privateData is void *, so we can't access
fields of parallelsConn, pointer to which is stored in
virConnect.privateData. So replace all occurences of
conn->privateData->storageState with privconn->storageState.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2014-12-02 16:31:13 +01:00
John Ferlan
b09ff13848 storage: Add mixed fc_host/scsi_host duplicate adapter source checks
https://bugzilla.redhat.com/show_bug.cgi?id=1159180

The virStoragePoolSourceFindDuplicate only checks the incoming definition
against the same type of pool as the def; however, for "scsi_host" and
"fc_host" adapter pools, it's possible that either some pool "scsi_host"
adapter definition is already using the scsi_hostN that the "fc_host"
adapter definition wants to use or some "fc_host" pool adapter definition
is using a vHBA scsi_hostN or parent scsi_hostN that an incoming "scsi_host"
definition is trying to use.

This patch adds the mismatched type checks and adds extraneous comments
to describe what each check is determining.

This patch also modifies the documentation to be describe what scsi_hostN
devices a "scsi_host" source adapter should use and which to avoid. It also
updates the parent definition to specifically call out that for mixed
environments it's better to define which parent to use so that the duplicate
pool checks can be done properly.
2014-12-01 10:04:25 -05:00
Daniel P. Berrange
cfacca18fa Update Parallels driver to always use privateData
Since the secondary drivers are only active when the primary
driver is also the Parallels driver, there is no need to use the
different type specific privateData fields. The object that was
being stored in the storagePrivateData can easily be kept in the
parallelsConn struct instead.
2014-11-07 11:12:50 +01:00
Daniel P. Berrange
931dff992e Rename virDriver to virHypervisorDriver
To prepare for introducing a single global driver, rename the
virDriver struct to virHypervisorDriver and the registration
API to virRegisterHypervisorDriver()
2014-10-23 11:09:54 +01:00
Peter Krempa
0b73366945 Implement empty post parse callbacks for all drivers
To allow easy implementation of a callback check this patch adds empty
post parse callbacks to drivers that were missing them.
2014-10-15 10:27:51 +02:00
Dmitry Guryanov
e7bb373fdf parallels: login to parallels SDK
Add files parallels_sdk.c and parallels_sdk.h for code
which works with SDK, so libvirt's code will not mix with
dealing with parallels SDK.

To use Parallels SDK you must first call PrlApi_InitEx function,
and then you will be able to connect to a server with
PrlSrv_LoginLocalEx function. When you've done you must call
PrlApi_Deinit. So let's call PrlApi_InitEx on first .connectOpen,
count number of connections and deinitialize, when this counter
becomes zero.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
2014-09-25 15:42:32 +02:00
John Ferlan
0da9a8a8bf parallels: Resolve Coverity USE_AFTER_FREE
Coverity complains that calling virNetworkDefFree(def), then jumping
to the cleanup: label which calls virNetworkDefFree(def) could result
in a double_free.  Just remove the call from the if statement.
2014-08-27 12:52:26 -04:00
Alexander Burluka
24b1bad37f Parallels: Change config report errors code.
Wrong error code in config errors reporting was used. Fixed it.
2014-08-22 14:31:29 +02:00
Alexander Burluka
268b4c84e0 Parallels: fix error with video card RAM dimension
Libvirt measures vram in Kbytes, not in bytes, so calculation
of Mbytes was incorrect. PCS server can take vram argument
with units, so I added K postfix to make params a little bit clearer.
2014-08-22 14:31:11 +02:00