RE: [libvirt] [RFC] Support for CPUID masking v2

2009-09-13 Thread Itamar Heim
 From: libvir-list-boun...@redhat.com [mailto:libvir-list-
 Hi,
 
 This is an attempt to provide similar flexibility to CPU ID masking
 without
 being x86-specific and unfriendly to users. As suggested by Dan, we need
a
 way
 to specify both CPU flags and topology to achieve this goal.
 
 
 Firstly, CPU topology and all (actually all that libvirt knows about)
CPU
 features have to be advertised in host capabilities:
 
 host
 cpu
 ...
 features
 featureNAME/feature
 /features
 topology
 socketsNUMBER_OF_SOCKETS/sockets
 coresCORES_PER_SOCKET/cores
 threadsTHREADS_PER_CORE/threads
 /topology
 /cpu
 ...
 /host
 
 I'm not 100% sure we should represent CPU features as
 featureNAME/feature
 especially because some features are currently advertised as NAME/.
 However,
 extending XML schema every time a new feature is introduced doesn't look
 like
 a good idea at all. The problem is we can't get rid of NAME/-style
 features,
 which would result in redundancy:
 
 features
 vmx/
 featurevmx/feature
 /features
 
 But I think it's better than changing the schema to add new features.
 
 
 
 Secondly, drivers which support detailed CPU specification have to
 advertise
 it in guest capabilities. In case features are meant to be hypervisor
 features, than it could look like:
 
 guest
 ...
 features
 cpu/
 /features
 /guest
 
 But if they are meant to be CPU features, we need to come up with
 something
 else:
 
 guest
 ...
 cpu_selection/
 /guest
 
 I'm not sure how to deal with named CPUs suggested by Dan. Either we
need
 to
 come up with global set of named CPUs and document what they mean or let
 drivers specify their own named CPUs and advertise them through guest
 capabilities:
 
 guest
 ...
 cpu model=NAME
 featureNAME/feature
 ...
 /cpu
 /guest
[IH] you also need to support removing a feature from the base cpu model,
if it is disabled by bios, like the nx flag).
 
 The former approach would make matching named CPUs with those defined by
a
 hypervisor (such as qemu) quite hard. The latter could bring the need
for
 hardcoding features provided by specific CPU models or, in case we
decide
 not
 to provide a list of features for each CPU model, it can complicate
 transferring a domain from one hypervisor to another.
 
 
 And finally, CPU may be configured in domain XML configuration:
 
 domain
 ...
 cpu model=NAME
 topology
 socketsNUMBER_OF_SOCKETS/sockets
 coresCORES_PER_SOCKET/cores
 threadsTHREADS_PER_CORE/threads
 /topology
 
 feature name=NAME mode=set|check value=on|off/
 /cpu
 /domain
 
 Mode 'check' checks physical CPU for the feature and refuses the domain
to
 start if it doesn't match. VCPU feature is set to the same value. Mode
 'set'
 just sets the VCPU feature.
 
 
 Final note: topology could also be called cpu_topology to avoid
 confusion
 with NUMA topology, which is used in host capabilities. However, I
 prefer
 cputopology.../topology/cpu over
 cpucpu_topology.../cpu_topology/cpu.
 
 Thanks for your comments.
 
 Jirka
 
 --
 Libvir-list mailing list
 Libvir-list@redhat.com
 https://www.redhat.com/mailman/listinfo/libvir-list

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] Re: [Qemu-devel] Re: [PATCH 0/2] port over extboot from kvm

2009-09-13 Thread Kevin O'Connor
On Tue, Sep 08, 2009 at 04:40:15PM +0200, Jan Kiszka wrote:
 Gerd Hoffmann wrote:
  On 09/08/09 15:47, Jan Kiszka wrote:
- This is just an implementation detail: Do we really need to implement
  booting from virtio and scsi via an extension rom? Isn't it possible
  to merge the corresponding support into the main bios?
  
  Well.  There are quite a few.  bochs pcbios, seabios, coreboot ...
 
 Ok, but that's only an argument to have extboot as a workaround for
 bioses not yet supporting scsi and virtio natively, isn't it? I'm
 thinking long-term here, not arguing against a extboot-based short-term
 solution.

I doubt we'll see native scsi support as I believe each scsi
controller needs its own initialization.  However, usb booting will
bring along with it mass storage class support.

I'm not familiar with virtio, however, I don't think it would be
difficult to add support to SeaBIOS.  The disk access code in SeaBIOS
has an intermediate layer which makes it easier to add new backends.
For an example of this, see the ramdisk.c code:

http://git.linuxtogo.org/?p=kevin/seabios.git;a=blob;f=src/ramdisk.c;h=7ac72f82befebb9fc6f18838c24044ace2312b1f;hb=HEAD

The above code adds support for a virtual floppy drive that is
populated with a floppy image stored in flash (useful with coreboot).

Basically, its possible to add driver support by adding a new drive
type (eg, DTYPE_RAMDISK) and implementing a new drive handler (eg,
process_ramdisk_op).  The handler just has to implement read and write
capability - the bios call handlers, interfaces, and lba manipulation
are handled by SeaBIOS.

-Kevin

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] Interface driver and ESX support

2009-09-13 Thread Shahar Klein
I've defined (among others):
int esxVI_PhysicalNic_CastListFromAnyType(virConnectPtr conn, esxVI_AnyType 
*anyType, esxVI_PhysicalNic **pNicList);
but runing it returns somthing like:
Expecting type 'PhysicalNic' but found 'ArrayOfPhysicalNic'

Does it mean I should also implement:
esxVI_ArrayOfPhysicalNic_CastListFromAnyType()

and all the funcs/type definition coming with it?

thanks
Shahar



From: Matthias Bolte matthias.bo...@googlemail.com
To: Shahar Klein shaharkl...@yahoo.com
Cc: libvir-list@redhat.com
Sent: Thursday, September 10, 2009 6:24:25 PM
Subject: Re: [libvirt] Interface driver and ESX support

2009/9/10 Shahar Klein shaharkl...@yahoo.com:
 I'm not sure what you mean about mapping
 lets take the pnics as a study case for me
 do I need to define a structure similar to this:
 http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.host.PhysicalNic.html
 and also take care for it's allocation?


Yes, you need to implement the mapping (a better word may be
'binding') of this VI API type to a C type, that also includes to care
about its allocation. You'll need to implement at least this set of
function in esx_vi_types.[ch]:

esxVI_PhysicalNic_Alloc()
esxVI_PhysicalNic_Free()
esxVI_PhysicalNic_CastFromAnyType()
esxVI_PhysicalNic_CastListFromAnyType()
esxVI_PhysicalNic_Deserialize()
esxVI_PhysicalNic_DeserializeList()

You could use the binding for the HostCpuIdInfo type, but
unfortunately I haven't published the code for it yet. This code also
includes some essential helper functions for
esxVI_PhysicalNic_CastListFromAnyType().

Beside the PhysicalNic type, you may also have to bind the types of
its members like PhysicalNicLinkInfo, PhysicalNicSpec and
HostIpConfig, if you need or care about the information provided by
them.

The binding for HostCpuIdInfo is part of a larger set of patches that
add some new features to ESX driver, but the patches needs some
cleanup first. I may have some time later this evening to clean them
up and post them.

PS: You should refer to version 2.5 of the VI API [1] and not 4.0,
because the complete VI API mapping is currently based on version 2.5.
At some point I'll have to properly distinguish between version 2.5
and 4.0, but currently I would like to stick to version 2.5 only.

[1] http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/

Matthias



  --
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] Interface driver and ESX support

2009-09-13 Thread Matthias Bolte
No, as I said before you should wait until you can use the unpublished
binding of HostCpuIdInfo as an example. This also includes the code to
handle ArrayOf* types. I'm currently cleaning up this patches (didn't
have time on thursday for that) and will post them today, just wait
for this patches, because they will help you.

Matthias

2009/9/13 Shahar Klein shaharkl...@yahoo.com:
 I've defined (among others):
 int esxVI_PhysicalNic_CastListFromAnyType(virConnectPtr conn, esxVI_AnyType
 *anyType, esxVI_PhysicalNic **pNicList);
 but runing it returns somthing like:
 Expecting type 'PhysicalNic' but found 'ArrayOfPhysicalNic'
 Does it mean I should also implement:
 esxVI_ArrayOfPhysicalNic_CastListFromAnyType()
 and all the funcs/type definition coming with it?
 thanks
 Shahar
 
 From: Matthias Bolte matthias.bo...@googlemail.com
 To: Shahar Klein shaharkl...@yahoo.com
 Cc: libvir-list@redhat.com
 Sent: Thursday, September 10, 2009 6:24:25 PM
 Subject: Re: [libvirt] Interface driver and ESX support

 2009/9/10 Shahar Klein shaharkl...@yahoo.com:
 I'm not sure what you mean about mapping
 lets take the pnics as a study case for me
 do I need to define a structure similar to this:

 http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.host.PhysicalNic.html
 and also take care for it's allocation?


 Yes, you need to implement the mapping (a better word may be
 'binding') of this VI API type to a C type, that also includes to care
 about its allocation. You'll need to implement at least this set of
 function in esx_vi_types.[ch]:

 esxVI_PhysicalNic_Alloc()
 esxVI_PhysicalNic_Free()
 esxVI_PhysicalNic_CastFromAnyType()
 esxVI_PhysicalNic_CastListFromAnyType()
 esxVI_PhysicalNic_Deserialize()
 esxVI_PhysicalNic_DeserializeList()

 You could use the binding for the HostCpuIdInfo type, but
 unfortunately I haven't published the code for it yet. This code also
 includes some essential helper functions for
 esxVI_PhysicalNic_CastListFromAnyType().

 Beside the PhysicalNic type, you may also have to bind the types of
 its members like PhysicalNicLinkInfo, PhysicalNicSpec and
 HostIpConfig, if you need or care about the information provided by
 them.

 The binding for HostCpuIdInfo is part of a larger set of patches that
 add some new features to ESX driver, but the patches needs some
 cleanup first. I may have some time later this evening to clean them
 up and post them.

 PS: You should refer to version 2.5 of the VI API [1] and not 4.0,
 because the complete VI API mapping is currently based on version 2.5.
 At some point I'll have to properly distinguish between version 2.5
 and 4.0, but currently I would like to stick to version 2.5 only.

 [1]
 http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/

 Matthias



--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] Passing -no-kvm-irqchip to KVM/QEMU guests

2009-09-13 Thread Garry Dolley
Dear libvirt,

Is there a way to tell a KVM/QEMU guest managed by libvirt to start
with the -no-kvm-irqchip argument?

I have some FreeBSD 7 guests with timing issues, and if I try to
start the VMs manually with -no-kvm-irqchip, the timing issues go
away (the only known workaround right now).

However, if the guest is managed by libvirt, I have found no way to
pass this command line option.

I'm running libvirt 0.6.4 on Ubuntu 9.04

Thoughts?

-- 
Garry Dolley
ARP Networks, Inc. | http://www.arpnetworks.com | (818) 206-0181
Data center, VPS, and IP Transit solutions
Member Los Angeles County REACT, Unit 336 | WQGK336
Blog http://scie.nti.st

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] ESX [01/12]: Add esxNodeGetFreeMemory()

2009-09-13 Thread Matthias Bolte
* src/esx/esx_driver.c: add esxNodeGetFreeMemory(), cache IP address
* src/esx/esx_vi.[ch]: refactor resource pool query into esxVI_GetResourcePool()
* src/esx/esx_vi_types.[ch]: bind VI type ResourcePoolResourceUsage
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 8d1af71..fb4edbc 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -139,7 +139,8 @@ static virDrvOpenStatus
 esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
 {
 esxPrivate *priv = NULL;
-char ipAddress[NI_MAXHOST] = ;
+char hostIpAddress[NI_MAXHOST] = ;
+char vCenterIpAddress[NI_MAXHOST] = ;
 char *url = NULL;
 char *vCenter = NULL;
 int noVerify = 0; // boolean
@@ -189,13 +190,13 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
 goto failure;
 }
 
-if (esxUtil_ResolveHostname(conn, conn-uri-server, ipAddress,
+if (esxUtil_ResolveHostname(conn, conn-uri-server, hostIpAddress,
 NI_MAXHOST)  0) {
 goto failure;
 }
 
 if (vCenter != NULL 
-esxUtil_ResolveHostname(conn, vCenter, ipAddress,
+esxUtil_ResolveHostname(conn, vCenter, vCenterIpAddress,
 NI_MAXHOST)  0) {
 goto failure;
 }
@@ -256,8 +257,8 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
 goto failure;
 }
 
-if (esxVI_Context_Connect(conn, priv-host, url, username,
-  password, noVerify)  0) {
+if (esxVI_Context_Connect(conn, priv-host, url, hostIpAddress,
+  username, password, noVerify)  0) {
 goto failure;
 }
 
@@ -309,8 +310,9 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
 goto failure;
 }
 
-if (esxVI_Context_Connect(conn, priv-vCenter, url, username,
-  password, noVerify)  0) {
+if (esxVI_Context_Connect(conn, priv-vCenter, url,
+  vCenterIpAddress, username, password,
+  noVerify)  0) {
 goto failure;
 }
 
@@ -2827,9 +2829,6 @@ esxDomainMigratePerform(virDomainPtr domain,
 esxVI_ObjectContent *virtualMachine = NULL;
 esxVI_String *propertyNameList = NULL;
 esxVI_ObjectContent *hostSystem = NULL;
-esxVI_DynamicProperty *dynamicProperty = NULL;
-esxVI_ManagedObjectReference *managedObjectReference = NULL;
-esxVI_ObjectContent *computeResource = NULL;
 esxVI_ManagedObjectReference *resourcePool = NULL;
 esxVI_Event *eventList = NULL;
 esxVI_ManagedObjectReference *task = NULL;
@@ -2879,69 +2878,13 @@ esxDomainMigratePerform(virDomainPtr domain,
 
 if (esxVI_String_AppendValueToList(domain-conn, propertyNameList,
parent)  0 ||
-esxVI_LookupHostSystemByIp(domain-conn, priv-vCenter,
-   hostIpAddress, propertyNameList,
-   hostSystem)  0) {
+esxVI_LookupHostSystemByIp(domain-conn, priv-vCenter, hostIpAddress,
+   propertyNameList, hostSystem)  0) {
 goto failure;
 }
 
-for (dynamicProperty = hostSystem-propSet; dynamicProperty != NULL;
- dynamicProperty = dynamicProperty-_next) {
-if (STREQ(dynamicProperty-name, parent)) {
-if (esxVI_ManagedObjectReference_CastFromAnyType
-  (domain-conn, dynamicProperty-val, managedObjectReference,
-   ComputeResource)  0) {
-goto failure;
-}
-
-break;
-} else {
-VIR_WARN(Unexpected '%s' property, dynamicProperty-name);
-}
-}
-
-if (managedObjectReference == NULL) {
-ESX_ERROR(domain-conn, VIR_ERR_INTERNAL_ERROR,
-  Could not retrieve compute resource of host system);
-goto failure;
-}
-
-esxVI_String_Free(propertyNameList);
-
-if (esxVI_String_AppendValueToList(domain-conn, propertyNameList,
-   resourcePool)  0 ||
-esxVI_GetObjectContent(domain-conn, priv-vCenter,
-   managedObjectReference, ComputeResource,
-   propertyNameList, esxVI_Boolean_False,
-   computeResource)  0) {
-goto failure;
-}
-
-if (computeResource == NULL) {
-ESX_ERROR(domain-conn, VIR_ERR_INTERNAL_ERROR,
-  Could not retrieve compute resource of host system);
-goto failure;
-}
-
-for (dynamicProperty = computeResource-propSet; dynamicProperty != NULL;
- dynamicProperty = dynamicProperty-_next) {
-if (STREQ(dynamicProperty-name, 

[libvirt] ESX [02/12]: Set challenge for auth callback to hostname

2009-09-13 Thread Matthias Bolte
This enables the auth callback to automatically distinguish between
requests for ESX host and vCenter credentials.

* src/esx/esx_util.[ch]: set challenge for auth callback to hostname
diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
index 92af0ca..38014de 100644
--- a/src/esx/esx_util.c
+++ b/src/esx/esx_util.c
@@ -50,7 +50,7 @@
 
 char *
 esxUtil_RequestUsername(virConnectAuthPtr auth, const char *defaultUsername,
-const char *server)
+const char *hostname)
 {
 unsigned int ncred;
 virConnectCredential cred;
@@ -58,7 +58,7 @@ esxUtil_RequestUsername(virConnectAuthPtr auth, const char *defaultUsername,
 
 memset(cred, 0, sizeof(virConnectCredential));
 
-if (virAsprintf(prompt, Enter username for %s [%s], server,
+if (virAsprintf(prompt, Enter username for %s [%s], hostname,
 defaultUsername)  0) {
 return NULL;
 }
@@ -70,7 +70,7 @@ esxUtil_RequestUsername(virConnectAuthPtr auth, const char *defaultUsername,
 
 cred.type = VIR_CRED_AUTHNAME;
 cred.prompt = prompt;
-cred.challenge = NULL;
+cred.challenge = hostname;
 cred.defresult = defaultUsername;
 cred.result = NULL;
 cred.resultlen = 0;
@@ -91,7 +91,7 @@ esxUtil_RequestUsername(virConnectAuthPtr auth, const char *defaultUsername,
 
 char *
 esxUtil_RequestPassword(virConnectAuthPtr auth, const char *username,
-const char *server)
+const char *hostname)
 {
 unsigned int ncred;
 virConnectCredential cred;
@@ -100,7 +100,7 @@ esxUtil_RequestPassword(virConnectAuthPtr auth, const char *username,
 memset(cred, 0, sizeof(virConnectCredential));
 
 if (virAsprintf(prompt, Enter %s password for %s, username,
-server)  0) {
+hostname)  0) {
 return NULL;
 }
 
@@ -112,7 +112,7 @@ esxUtil_RequestPassword(virConnectAuthPtr auth, const char *username,
 
 cred.type = auth-credtype[ncred];
 cred.prompt = prompt;
-cred.challenge = NULL;
+cred.challenge = hostname;
 cred.defresult = NULL;
 cred.result = NULL;
 cred.resultlen = 0;
diff --git a/src/esx/esx_util.h b/src/esx/esx_util.h
index 9c31715..476e004 100644
--- a/src/esx/esx_util.h
+++ b/src/esx/esx_util.h
@@ -30,10 +30,10 @@
 
 char *esxUtil_RequestUsername(virConnectAuthPtr auth,
   const char *defaultUsername,
-  const char *server);
+  const char *hostname);
 
 char *esxUtil_RequestPassword(virConnectAuthPtr auth, const char *username,
-  const char *server);
+  const char *hostname);
 
 int esxUtil_ParseQuery(virConnectPtr conn, char **transport, char **vCenter,
int *noVerify);
--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] ESX [05/12]: Also strip (C) and (TM) from the CPU model string

2009-09-13 Thread Matthias Bolte
* src/esx/esx_driver.c: also strip (C) and (TM) from the CPU model string
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 3f3ee30..96d5976 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -746,9 +746,12 @@ esxNodeGetInfo(virConnectPtr conn, virNodeInfoPtr nodeinfo)
 if (STRPREFIX (ptr,   )) {
 memmove(ptr, ptr + 1, strlen (ptr + 1) + 1);
 continue;
-} else if (STRPREFIX (ptr, (R))) {
+} else if (STRPREFIX(ptr, (R)) || STRPREFIX(ptr, (C))) {
 memmove(ptr, ptr + 3, strlen (ptr + 3) + 1);
 continue;
+} else if (STRPREFIX(ptr, (TM))) {
+memmove(ptr, ptr + 4, strlen(ptr + 4) + 1);
+continue;
 }
 
 ++ptr;
--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] ESX [06/12]: Add x86_64 detection based on the CPUID

2009-09-13 Thread Matthias Bolte
* src/esx/esx_driver.c: add esxSupportsLongMode() and update esxCapsInit()
* src/esx/esx_vi.[ch]: Add AnyType handling for lists
* src/esx/esx_vi_types.c: bind VI type HostCpuIdInfo
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 96d5976..745b744 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -27,6 +27,7 @@
  * - Memory model:http://www.vmware.com/pdf/esx3_memory.pdf
  * - VI API reference:http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/
  * - VMX-file parameters: http://www.sanbarrow.com/vmx.html
+ * - CPUID:   http://www.sandpile.org/ia32/cpuid.htm
  */
 
 #include config.h
@@ -62,19 +63,144 @@ typedef struct _esxPrivate {
 char *transport;
 int32_t maxVcpus;
 esxVI_Boolean supportsVMotion;
+esxVI_Boolean supportsLongMode; /* aka x86_64 */
 int32_t usedCpuTimeCounterId;
 } esxPrivate;
 
 
 
+static esxVI_Boolean
+esxSupportsLongMode(virConnectPtr conn)
+{
+esxPrivate *priv = (esxPrivate *)conn-privateData;
+esxVI_String *propertyNameList = NULL;
+esxVI_ObjectContent *hostSystem = NULL;
+esxVI_DynamicProperty *dynamicProperty = NULL;
+esxVI_HostCpuIdInfo *hostCpuIdInfoList = NULL;
+esxVI_HostCpuIdInfo *hostCpuIdInfo = NULL;
+char edxLongModeBit = '?';
+char edxFirstBit = '?';
+
+if (priv-phantom) {
+ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID,
+  Not possible with a phantom connection);
+goto failure;
+}
+
+if (priv-supportsLongMode != esxVI_Boolean_Undefined) {
+return priv-supportsLongMode;
+}
+
+if (esxVI_EnsureSession(conn, priv-host)  0) {
+goto failure;
+}
+
+if (esxVI_String_AppendValueToList(conn, propertyNameList,
+   hardware.cpuFeature)  0 ||
+esxVI_GetObjectContent(conn, priv-host, priv-host-hostFolder,
+   HostSystem, propertyNameList,
+   esxVI_Boolean_True, hostSystem)  0) {
+goto failure;
+}
+
+if (hostSystem == NULL) {
+ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
+  Could not retrieve the HostSystem object);
+goto failure;
+}
+
+for (dynamicProperty = hostSystem-propSet; dynamicProperty != NULL;
+ dynamicProperty = dynamicProperty-_next) {
+if (STREQ(dynamicProperty-name, hardware.cpuFeature)) {
+if (esxVI_HostCpuIdInfo_CastListFromAnyType
+  (conn, dynamicProperty-val, hostCpuIdInfoList)  0) {
+goto failure;
+}
+
+for (hostCpuIdInfo = hostCpuIdInfoList; hostCpuIdInfo != NULL;
+ hostCpuIdInfo = hostCpuIdInfo-_next) {
+if (hostCpuIdInfo-level-value == -2147483647) { /* 0x8001 */
+#define _SKIP4 %*c%*c%*c%*c
+#define _SKIP12 _SKIP4:_SKIP4:_SKIP4
+
+/* Expected format: --X-::::::: */
+if (sscanf(hostCpuIdInfo-edx,
+   %*c%*c%c%*c:_SKIP12:_SKIP12:%*c%*c%*c%c,
+   edxLongModeBit, edxFirstBit) != 2) {
+ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
+  HostSystem property 'hardware.cpuFeature[].edx' 
+  with value '%s' doesn't have expected format 
+  ':::::::',
+  hostCpuIdInfo-edx);
+goto failure;
+}
+
+#undef _SKIP4
+#undef _SKIP12
+
+if (edxLongModeBit == '1') {
+priv-supportsLongMode = esxVI_Boolean_True;
+} else if (edxLongModeBit == '0') {
+priv-supportsLongMode = esxVI_Boolean_False;
+} else {
+ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
+  Bit 29 (Long Mode) of HostSystem property 
+  'hardware.cpuFeature[].edx' with value '%s' 
+  has unexpected value '%c', expecting '0' 
+  or '1', hostCpuIdInfo-edx, edxLongModeBit);
+goto failure;
+}
+
+break;
+}
+}
+
+break;
+} else {
+VIR_WARN(Unexpected '%s' property, dynamicProperty-name);
+}
+}
+
+  cleanup:
+esxVI_String_Free(propertyNameList);
+esxVI_ObjectContent_Free(hostSystem);
+esxVI_HostCpuIdInfo_Free(hostCpuIdInfoList);
+
+return priv-supportsLongMode;
+
+  failure:
+priv-supportsLongMode = esxVI_Boolean_Undefined;
+
+goto cleanup;
+}
+
+
+
 static virCapsPtr
 esxCapsInit(virConnectPtr conn)
 {
+esxPrivate *priv = (esxPrivate 

[libvirt] ESX [07/12]: Whitespace cleanup

2009-09-13 Thread Matthias Bolte
Subject says it all.
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 745b744..8194b49 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -752,13 +752,13 @@ esxGetHostname(virConnectPtr conn)
 }
 }
 
-if (hostName == NULL || strlen (hostName)  1) {
+if (hostName == NULL || strlen(hostName)  1) {
 ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
   Missing or empty 'hostName' property);
 goto failure;
 }
 
-if (domainName == NULL || strlen (domainName)  1) {
+if (domainName == NULL || strlen(domainName)  1) {
 ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
   Missing or empty 'domainName' property);
 goto failure;
@@ -800,7 +800,7 @@ esxNodeGetInfo(virConnectPtr conn, virNodeInfoPtr nodeinfo)
 int32_t numaInfo_numNodes = 0;
 char *ptr = NULL;
 
-memset (nodeinfo, 0, sizeof (virNodeInfo));
+memset(nodeinfo, 0, sizeof(virNodeInfo));
 
 if (priv-phantom) {
 ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID,
@@ -891,11 +891,11 @@ esxNodeGetInfo(virConnectPtr conn, virNodeInfoPtr nodeinfo)
 
 /* Strip the string to fit more relevant information in 32 chars */
 while (*ptr != '\0') {
-if (STRPREFIX (ptr,   )) {
-memmove(ptr, ptr + 1, strlen (ptr + 1) + 1);
+if (STRPREFIX(ptr,   )) {
+memmove(ptr, ptr + 1, strlen(ptr + 1) + 1);
 continue;
 } else if (STRPREFIX(ptr, (R)) || STRPREFIX(ptr, (C))) {
-memmove(ptr, ptr + 3, strlen (ptr + 3) + 1);
+memmove(ptr, ptr + 3, strlen(ptr + 3) + 1);
 continue;
 } else if (STRPREFIX(ptr, (TM))) {
 memmove(ptr, ptr + 4, strlen(ptr + 4) + 1);
@@ -905,9 +905,9 @@ esxNodeGetInfo(virConnectPtr conn, virNodeInfoPtr nodeinfo)
 ++ptr;
 }
 
-strncpy (nodeinfo-model, dynamicProperty-val-string,
- sizeof (nodeinfo-model) - 1);
-nodeinfo-model[sizeof (nodeinfo-model) - 1] = '\0';
+strncpy(nodeinfo-model, dynamicProperty-val-string,
+sizeof(nodeinfo-model) - 1);
+nodeinfo-model[sizeof(nodeinfo-model) - 1] = '\0';
 } else {
 VIR_WARN(Unexpected '%s' property, dynamicProperty-name);
 }
@@ -1196,7 +1196,7 @@ esxDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
 }
 
 if (memcmp(uuid, uuid_candidate,
-   VIR_UUID_BUFLEN * sizeof (unsigned char)) != 0) {
+   VIR_UUID_BUFLEN * sizeof(unsigned char)) != 0) {
 continue;
 }
 
@@ -2732,7 +2732,7 @@ esxDomainGetSchedulerParameters(virDomainPtr domain,
  dynamicProperty != NULL  mask != 7  i  3;
  dynamicProperty = dynamicProperty-_next) {
 if (STREQ(dynamicProperty-name, config.cpuAllocation.reservation) 
-!(mask  (1  0))) {
+! (mask  (1  0))) {
 snprintf (params[i].field, VIR_DOMAIN_SCHED_FIELD_LENGTH, %s,
   reservation);
 
@@ -2748,7 +2748,7 @@ esxDomainGetSchedulerParameters(virDomainPtr domain,
 ++i;
 } else if (STREQ(dynamicProperty-name,
  config.cpuAllocation.limit) 
-   !(mask  (1  1))) {
+   ! (mask  (1  1))) {
 snprintf (params[i].field, VIR_DOMAIN_SCHED_FIELD_LENGTH, %s,
   limit);
 
@@ -2764,7 +2764,7 @@ esxDomainGetSchedulerParameters(virDomainPtr domain,
 ++i;
 } else if (STREQ(dynamicProperty-name,
  config.cpuAllocation.shares) 
-   !(mask  (1  2))) {
+   ! (mask  (1  2))) {
 snprintf (params[i].field, VIR_DOMAIN_SCHED_FIELD_LENGTH, %s,
   shares);
 
diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
index 38014de..7130a41 100644
--- a/src/esx/esx_util.c
+++ b/src/esx/esx_util.c
@@ -271,7 +271,7 @@ esxUtil_ResolveHostname(virConnectPtr conn, const char *hostname,
 struct addrinfo *result = NULL;
 int errcode;
 
-memset(hints, 0, sizeof (struct addrinfo));
+memset(hints, 0, sizeof(struct addrinfo));
 
 hints.ai_flags = AI_ADDRCONFIG;
 hints.ai_family = AF_INET;
@@ -455,12 +455,12 @@ esxUtil_GetConfigLong(virConnectPtr conn, virConfPtr conf, const char *name,
 
 int
 esxUtil_GetConfigBoolean(virConnectPtr conn, virConfPtr conf,
- const char *name, int *boolval, int default_,
+ const char *name, int *boolean_, int default_,
  int optional)
 {
 virConfValuePtr value;
 
-*boolval = default_;
+*boolean_ = default_;
 value = virConfGetValue(conf, name);
 
 if (value == NULL) {
@@ -485,9 +485,9 @@ esxUtil_GetConfigBoolean(virConnectPtr conn, virConfPtr conf,
 

[libvirt] ESX [08/12]: Add esxVI_Occurence enum to describe expected occurence of items

2009-09-13 Thread Matthias Bolte
* src/esx/esx_driver.c: update the use of esxVI_LookupVirtualMachineByUuid()
* src/esx/esx_vi.c: add an esxVI_Occurence parameter to
  esxVI_LookupVirtualMachineByUuid() and take care if esxVI_FindByUuid() can't
  find anything for a given uuid
* src/esx/esx_vi.h: add esxVI_Occurence enum
* src/esx/esx_vi_methods.c: expect null or more items to be returned from
  esxVI_FindByUuid()
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 8194b49..85f9e4c 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -1356,7 +1356,8 @@ esxDomainSuspend(virDomainPtr domain)
runtime.powerState)  0 ||
 esxVI_LookupVirtualMachineByUuid(domain-conn, priv-host,
  domain-uuid, propertyNameList,
- virtualMachine)  0 ||
+ virtualMachine,
+ esxVI_Occurence_RequiredItem)  0 ||
 esxVI_GetVirtualMachinePowerState(domain-conn, virtualMachine,
   powerState)  0) {
 goto failure;
@@ -1421,7 +1422,8 @@ esxDomainResume(virDomainPtr domain)
runtime.powerState)  0 ||
 esxVI_LookupVirtualMachineByUuid(domain-conn, priv-host,
  domain-uuid, propertyNameList,
- virtualMachine)  0 ||
+ virtualMachine,
+ esxVI_Occurence_RequiredItem)  0 ||
 esxVI_GetVirtualMachinePowerState(domain-conn, virtualMachine,
   powerState)  0) {
 goto failure;
@@ -1484,7 +1486,8 @@ esxDomainShutdown(virDomainPtr domain)
runtime.powerState)  0 ||
 esxVI_LookupVirtualMachineByUuid(domain-conn, priv-host,
  domain-uuid, propertyNameList,
- virtualMachine)  0 ||
+ virtualMachine,
+ esxVI_Occurence_RequiredItem)  0 ||
 esxVI_GetVirtualMachinePowerState(domain-conn, virtualMachine,
   powerState)  0) {
 goto failure;
@@ -1538,7 +1541,8 @@ esxDomainReboot(virDomainPtr domain, unsigned int flags ATTRIBUTE_UNUSED)
runtime.powerState)  0 ||
 esxVI_LookupVirtualMachineByUuid(domain-conn, priv-host,
  domain-uuid, propertyNameList,
- virtualMachine)  0 ||
+ virtualMachine,
+ esxVI_Occurence_RequiredItem)  0 ||
 esxVI_GetVirtualMachinePowerState(domain-conn, virtualMachine,
   powerState)  0) {
 goto failure;
@@ -1593,7 +1597,8 @@ esxDomainDestroy(virDomainPtr domain)
runtime.powerState)  0 ||
 esxVI_LookupVirtualMachineByUuid(domain-conn, priv-host,
  domain-uuid, propertyNameList,
- virtualMachine)  0 ||
+ virtualMachine,
+ esxVI_Occurence_RequiredItem)  0 ||
 esxVI_GetVirtualMachinePowerState(domain-conn, virtualMachine,
   powerState)  0) {
 goto failure;
@@ -1671,7 +1676,8 @@ esxDomainGetMaxMemory(virDomainPtr domain)
config.hardware.memoryMB)  0 ||
 esxVI_LookupVirtualMachineByUuid(domain-conn, priv-host,
  domain-uuid, propertyNameList,
- virtualMachine)  0) {
+ virtualMachine,
+ esxVI_Occurence_RequiredItem)  0) {
 goto failure;
 }
 
@@ -1733,7 +1739,8 @@ esxDomainSetMaxMemory(virDomainPtr domain, unsigned long memory)
 
 if (esxVI_LookupVirtualMachineByUuid(domain-conn, priv-host,
  domain-uuid, NULL,
- virtualMachine)  0 ||
+ virtualMachine,
+ esxVI_Occurence_RequiredItem)  0 ||
 esxVI_VirtualMachineConfigSpec_Alloc(domain-conn, spec)  0 ||
 esxVI_Long_Alloc(domain-conn, spec-memoryMB)  0) {
 goto failure;
@@ -1792,7 +1799,8 @@ esxDomainSetMemory(virDomainPtr domain, unsigned long memory)
 
 if (esxVI_LookupVirtualMachineByUuid(domain-conn, priv-host,
  domain-uuid, NULL,
-

[libvirt] ESX [10/12]: Replace esxUtil_EqualSuffix() with virFileHasSuffix()

2009-09-13 Thread Matthias Bolte
* src/esx/esx_util.[ch]: remove esxUtil_EqualSuffix()
* src/esx/esx_driver.c, src/esx/esx_vmx.c: replace esxUtil_EqualSuffix() with
  virFileHasSuffix()
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 9c9045e..5a93d1f 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -2690,7 +2690,7 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml ATTRIBUTE_UNUSED)
 goto failure;
 }
 
-if (! esxUtil_EqualSuffix(fileName, .vmdk)) {
+if (! virFileHasSuffix(fileName, .vmdk)) {
 ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
   Expecting source of first disk '%s' to be a VMDK image,
   def-disks[0]-src);
diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
index 67bbcb8..3e53921 100644
--- a/src/esx/esx_util.c
+++ b/src/esx/esx_util.c
@@ -585,17 +585,3 @@ esxUtil_GetConfigBoolean(virConnectPtr conn, virConfPtr conf,
 
 return 0;
 }
-
-
-
-int
-esxUtil_EqualSuffix(const char *string, const char *suffix)
-{
-int difference = (int)strlen(string) - (int)strlen(suffix);
-
-if (difference  0) {
-return -1;
-} else {
-return STRCASEEQ(string + difference, suffix);
-}
-}
diff --git a/src/esx/esx_util.h b/src/esx/esx_util.h
index 8e3f039..c466b44 100644
--- a/src/esx/esx_util.h
+++ b/src/esx/esx_util.h
@@ -61,6 +61,4 @@ int esxUtil_GetConfigBoolean(virConnectPtr conn, virConfPtr conf,
  const char *name, int *boolean_, int default_,
  int optional);
 
-int esxUtil_EqualSuffix(const char *string, const char *suffix);
-
 #endif /* __ESX_UTIL_H__ */
diff --git a/src/esx/esx_vmx.c b/src/esx/esx_vmx.c
index f9595f4..c98b847 100644
--- a/src/esx/esx_vmx.c
+++ b/src/esx/esx_vmx.c
@@ -982,7 +982,7 @@ esxVMX_ParseConfig(virConnectPtr conn, esxVI_Context *ctx, const char *vmx,
 goto failure;
 }
 
-if (guestOS != NULL  esxUtil_EqualSuffix(guestOS, -64)) {
+if (guestOS != NULL  virFileHasSuffix(guestOS, -64)) {
 def-os.arch = strdup(x86_64);
 } else {
 def-os.arch = strdup(i686);
@@ -1488,7 +1488,7 @@ esxVMX_ParseDisk(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf,
 
 /* Setup virDomainDiskDef */
 if (device == VIR_DOMAIN_DISK_DEVICE_DISK) {
-if (esxUtil_EqualSuffix(fileName, .vmdk)) {
+if (virFileHasSuffix(fileName, .vmdk)) {
 if (deviceType != NULL) {
 if (bus == VIR_DOMAIN_DISK_BUS_SCSI 
 STRCASENEQ(deviceType, scsi-hardDisk)) {
@@ -1524,7 +1524,7 @@ esxVMX_ParseDisk(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf,
 if ((*def)-src == NULL) {
 goto failure;
 }
-} else if (esxUtil_EqualSuffix(fileName, .iso) ||
+} else if (virFileHasSuffix(fileName, .iso) ||
STREQ(deviceType, atapi-cdrom)) {
 /*
  * This function was called in order to parse a harddisk device,
@@ -1540,7 +1540,7 @@ esxVMX_ParseDisk(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf,
 goto failure;
 }
 } else if (device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
-if (esxUtil_EqualSuffix(fileName, .iso)) {
+if (virFileHasSuffix(fileName, .iso)) {
 if (deviceType != NULL) {
 if (STRCASENEQ(deviceType, cdrom-image)) {
 ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
@@ -1557,7 +1557,7 @@ esxVMX_ParseDisk(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf,
 if ((*def)-src == NULL) {
 goto failure;
 }
-} else if (esxUtil_EqualSuffix(fileName, .vmdk)) {
+} else if (virFileHasSuffix(fileName, .vmdk)) {
 /*
  * This function was called in order to parse a CDROM device, but
  * .vmdk files are for harddisk devices only. Just ignore it,
@@ -1577,7 +1577,7 @@ esxVMX_ParseDisk(virConnectPtr conn, esxVI_Context *ctx, virConfPtr conf,
 goto failure;
 }
 } else if (device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
-if (esxUtil_EqualSuffix(fileName, .flp)) {
+if (virFileHasSuffix(fileName, .flp)) {
 if (fileType != NULL) {
 if (STRCASENEQ(fileType, file)) {
 ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
@@ -2444,7 +2444,7 @@ esxVMX_FormatHardDisk(virConnectPtr conn, esxVI_Context *ctx,
   entryPrefix, controller, id, deviceTypePrefix);
 
 if (def-src != NULL) {
-if (! esxUtil_EqualSuffix(def-src, .vmdk)) {
+if (! virFileHasSuffix(def-src, .vmdk)) {
 ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
   Image file for %s harddisk '%s' has unsupported suffix, 
   expecting '.vmdk', busName, def-dst);
@@ -2526,7 +2526,7 @@ esxVMX_FormatCDROM(virConnectPtr conn, esxVI_Context *ctx,
   entryPrefix, controller, id);
 
 if (def-src != NULL) {

[libvirt] ESX [11/12]: Reorder some function calls to avoid potential virDomainPtr leaks

2009-09-13 Thread Matthias Bolte
* src/esx/esx_driver.c: avoid potential virDomainPtr leaks
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 5a93d1f..91de407 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -1200,14 +1200,14 @@ esxDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
 continue;
 }
 
-domain = virGetDomain(conn, name_candidate, uuid_candidate);
-
-if (domain == NULL) {
+if (esxVI_GetVirtualMachinePowerState(conn, virtualMachine,
+  powerState)  0) {
 goto failure;
 }
 
-if (esxVI_GetVirtualMachinePowerState(conn, virtualMachine,
-  powerState)  0) {
+domain = virGetDomain(conn, name_candidate, uuid_candidate);
+
+if (domain == NULL) {
 goto failure;
 }
 
@@ -1291,14 +1291,14 @@ esxDomainLookupByName(virConnectPtr conn, const char *name)
 continue;
 }
 
-domain = virGetDomain(conn, name_candidate, uuid_candidate);
-
-if (domain == NULL) {
+if (esxVI_GetVirtualMachinePowerState(conn, virtualMachine,
+  powerState)  0) {
 goto failure;
 }
 
-if (esxVI_GetVirtualMachinePowerState(conn, virtualMachine,
-  powerState)  0) {
+domain = virGetDomain(conn, name_candidate, uuid_candidate);
+
+if (domain == NULL) {
 goto failure;
 }
 
--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] ESX [12/12]: Remove phantom mode

2009-09-13 Thread Matthias Bolte
* src/esx/esx_driver.c: remove phantom mode
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 91de407..bbba445 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -58,7 +58,6 @@ static int esxDomainGetMaxVcpus(virDomainPtr domain);
 typedef struct _esxPrivate {
 esxVI_Context *host;
 esxVI_Context *vCenter;
-int phantom; // boolean
 virCapsPtr caps;
 char *transport;
 int32_t maxVcpus;
@@ -81,12 +80,6 @@ esxSupportsLongMode(virConnectPtr conn)
 char edxLongModeBit = '?';
 char edxFirstBit = '?';
 
-if (priv-phantom) {
-ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID,
-  Not possible with a phantom connection);
-goto failure;
-}
-
 if (priv-supportsLongMode != esxVI_Boolean_Undefined) {
 return priv-supportsLongMode;
 }
@@ -179,19 +172,10 @@ esxSupportsLongMode(virConnectPtr conn)
 static virCapsPtr
 esxCapsInit(virConnectPtr conn)
 {
-esxPrivate *priv = (esxPrivate *)conn-privateData;
-esxVI_Boolean supportsLongMode = esxVI_Boolean_Undefined;
+esxVI_Boolean supportsLongMode = esxSupportsLongMode(conn);
 virCapsPtr caps = NULL;
 virCapsGuestPtr guest = NULL;
 
-if (priv-phantom) {
-ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID,
-  Not possible with a phantom connection);
-return NULL;
-}
-
-supportsLongMode = esxSupportsLongMode(conn);
-
 if (supportsLongMode == esxVI_Boolean_Undefined) {
 return NULL;
 }
@@ -258,7 +242,6 @@ esxCapsInit(virConnectPtr conn)
 
 /*
  * URI format: {esx|gsx}://[user@]server[:port][?transport={http|https}][vcenter=vcenter][no_verify={0|1}]
- * esx:///phantom
  *
  * If no port is specified the default port is set dependent on the scheme and
  * transport parameter:
@@ -274,11 +257,6 @@ esxCapsInit(virConnectPtr conn)
  *
  * If the no_verify parameter is set to 1, this disables libcurl client checks
  * of the server's certificate. The default value it 0.
- *
- * The esx:///phantom URI may be used for tasks that don't require an actual
- * connection to the hypervisor like domxml-{from,to}-native:
- *
- * virsh -c esx:///phantom domxml-from-native vmware-vmx dummy.vmx
  */
 static virDrvOpenStatus
 esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
@@ -291,7 +269,6 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
 int noVerify = 0; // boolean
 char *username = NULL;
 char *password = NULL;
-int phantom = 0; // boolean
 
 /* Decline if the URI is NULL or the scheme is neither 'esx' nor 'gsx' */
 if (conn-uri == NULL || conn-uri-scheme == NULL ||
@@ -300,21 +277,13 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
 return VIR_DRV_OPEN_DECLINED;
 }
 
-/* Check for 'esx:///phantom' URI */
-if (conn-uri-server == NULL  conn-uri-path != NULL 
-STREQ(conn-uri-path, /phantom)) {
-phantom = 1;
+/* Decline URIs without server part, or missing auth */
+if (conn-uri-server == NULL || auth == NULL || auth-cb == NULL) {
+return VIR_DRV_OPEN_DECLINED;
 }
 
-if (! phantom) {
-/* Decline non-phantom URIs without server part, or missing auth */
-if (conn-uri-server == NULL || auth == NULL || auth-cb == NULL) {
-return VIR_DRV_OPEN_DECLINED;
-}
-
-if (conn-uri-path != NULL) {
-VIR_WARN(Ignoring unexpected path '%s' in URI, conn-uri-path);
-}
+if (conn-uri-path != NULL) {
+VIR_WARN(Ignoring unexpected path '%s' in URI, conn-uri-path);
 }
 
 /* Allocate per-connection private data */
@@ -323,171 +292,164 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
 goto failure;
 }
 
-priv-phantom = phantom;
 priv-maxVcpus = -1;
 priv-supportsVMotion = esxVI_Boolean_Undefined;
 priv-supportsLongMode = esxVI_Boolean_Undefined;
 priv-usedCpuTimeCounterId = -1;
 
-/* Request credentials and login to non-phantom host/vCenter */
-if (! phantom) {
-if (esxUtil_ParseQuery(conn, priv-transport, vCenter,
-   noVerify)  0) {
-goto failure;
+/* Request credentials and login to host/vCenter */
+if (esxUtil_ParseQuery(conn, priv-transport, vCenter, noVerify)  0) {
+goto failure;
+}
+
+if (esxUtil_ResolveHostname(conn, conn-uri-server, hostIpAddress,
+NI_MAXHOST)  0) {
+goto failure;
+}
+
+if (vCenter != NULL 
+esxUtil_ResolveHostname(conn, vCenter, vCenterIpAddress,
+NI_MAXHOST)  0) {
+goto failure;
+}
+
+/*
+ * Set the port dependent on the transport protocol if no port is
+ * specified. This allows us to rely on the port parameter being
+ * correctly set when building URIs later on, without the need to
+ * 

Re: [libvirt] Interface driver and ESX support

2009-09-13 Thread Matthias Bolte
Okay, I finally got the patches cleaned up.

I just posted this 12 patches series to the mailing list. Apply them
all to an up to date git clone and apply the attached, updated ESX
interface driver stub patch in the end.

Patch 6 of 12 adds the binding for HostCpuIdInfo and contains the
functions to handle ArrayOf* types.

Matthias

2009/9/13 Shahar Klein shaharkl...@yahoo.com:
 I see
 You are making my (coding) life easier : )
 thanks
 
 From: Matthias Bolte matthias.bo...@googlemail.com
 To: Shahar Klein shaharkl...@yahoo.com
 Cc: libvir-list@redhat.com
 Sent: Sunday, September 13, 2009 4:39:22 PM
 Subject: Re: [libvirt] Interface driver and ESX support

 No, as I said before you should wait until you can use the unpublished
 binding of HostCpuIdInfo as an example. This also includes the code to
 handle ArrayOf* types. I'm currently cleaning up this patches (didn't
 have time on thursday for that) and will post them today, just wait
 for this patches, because they will help you.

 Matthias

 2009/9/13 Shahar Klein shaharkl...@yahoo.com:
 I've defined (among others):
 int esxVI_PhysicalNic_CastListFromAnyType(virConnectPtr conn,
 esxVI_AnyType
 *anyType, esxVI_PhysicalNic **pNicList);
 but runing it returns somthing like:
 Expecting type 'PhysicalNic' but found 'ArrayOfPhysicalNic'
 Does it mean I should also implement:
 esxVI_ArrayOfPhysicalNic_CastListFromAnyType()
 and all the funcs/type definition coming with it?
 thanks
 Shahar
 
 From: Matthias Bolte matthias.bo...@googlemail.com
 To: Shahar Klein shaharkl...@yahoo.com
 Cc: libvir-list@redhat.com
 Sent: Thursday, September 10, 2009 6:24:25 PM
 Subject: Re: [libvirt] Interface driver and ESX support

 2009/9/10 Shahar Klein shaharkl...@yahoo.com:
 I'm not sure what you mean about mapping
 lets take the pnics as a study case for me
 do I need to define a structure similar to this:


 http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.host.PhysicalNic.html
 and also take care for it's allocation?


 Yes, you need to implement the mapping (a better word may be
 'binding') of this VI API type to a C type, that also includes to care
 about its allocation. You'll need to implement at least this set of
 function in esx_vi_types.[ch]:

 esxVI_PhysicalNic_Alloc()
 esxVI_PhysicalNic_Free()
 esxVI_PhysicalNic_CastFromAnyType()
 esxVI_PhysicalNic_CastListFromAnyType()
 esxVI_PhysicalNic_Deserialize()
 esxVI_PhysicalNic_DeserializeList()

 You could use the binding for the HostCpuIdInfo type, but
 unfortunately I haven't published the code for it yet. This code also
 includes some essential helper functions for
 esxVI_PhysicalNic_CastListFromAnyType().

 Beside the PhysicalNic type, you may also have to bind the types of
 its members like PhysicalNicLinkInfo, PhysicalNicSpec and
 HostIpConfig, if you need or care about the information provided by
 them.

 The binding for HostCpuIdInfo is part of a larger set of patches that
 add some new features to ESX driver, but the patches needs some
 cleanup first. I may have some time later this evening to clean them
 up and post them.

 PS: You should refer to version 2.5 of the VI API [1] and not 4.0,
 because the complete VI API mapping is currently based on version 2.5.
 At some point I'll have to properly distinguish between version 2.5
 and 4.0, but currently I would like to stick to version 2.5 only.

 [1]
 http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/

 Matthias




diff --git a/src/Makefile.am b/src/Makefile.am
index 14a3a63..5a50402 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -170,6 +170,7 @@ ONE_DRIVER_SOURCES =		\
 
 ESX_DRIVER_SOURCES =		\
 		esx/esx_driver.c esx/esx_driver.h		\
+		esx/esx_interface_driver.c esx/esx_interface_driver.h		\
 		esx/esx_util.c esx/esx_util.h			\
 		esx/esx_vi.c esx/esx_vi.h			\
 		esx/esx_vi_methods.c esx/esx_vi_methods.h	\
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index bbba445..cdecc57 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -42,6 +42,7 @@
 #include logging.h
 #include uuid.h
 #include esx_driver.h
+#include esx_interface_driver.h
 #include esx_vi.h
 #include esx_vi_methods.h
 #include esx_util.h
@@ -55,17 +56,6 @@
 
 static int esxDomainGetMaxVcpus(virDomainPtr domain);
 
-typedef struct _esxPrivate {
-esxVI_Context *host;
-esxVI_Context *vCenter;
-virCapsPtr caps;
-char *transport;
-int32_t maxVcpus;
-esxVI_Boolean supportsVMotion;
-esxVI_Boolean supportsLongMode; /* aka x86_64 */
-int32_t usedCpuTimeCounterId;
-} esxPrivate;
-
 
 
 static esxVI_Boolean
@@ -3276,7 +3266,13 @@ static virDriver esxDriver = {
 int
 esxRegister(void)
 {
-virRegisterDriver(esxDriver);
+if (virRegisterDriver(esxDriver)  0) {
+return -1;
+}
+
+if (esxInterfaceRegister()  0) {
+return -1;
+}
 
 return 0;
 }
diff --git a/src/esx/esx_driver.h 

Re: [libvirt] Passing -no-kvm-irqchip to KVM/QEMU guests

2009-09-13 Thread Jim Paris
Garry Dolley wrote:
 Dear libvirt,
 
 Is there a way to tell a KVM/QEMU guest managed by libvirt to start
 with the -no-kvm-irqchip argument?
 
 I have some FreeBSD 7 guests with timing issues, and if I try to
 start the VMs manually with -no-kvm-irqchip, the timing issues go
 away (the only known workaround right now).
 
 However, if the guest is managed by libvirt, I have found no way to
 pass this command line option.
 
 I'm running libvirt 0.6.4 on Ubuntu 9.04

As a hack, you can point the XML file to a wrapper script instead of
the KVM binary, where the script would contain e.g.:

  #!/bin/sh
  exec /usr/bin/kvm $@ -no-kvm-irqchip

-jim

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list