[libvirt] [RFC] Adding a none model for video cards

2014-07-30 Thread Jean-Baptiste Rouault
Hi,

I'm trying to run vexpress-a9 virtual machines (armv7l architecture) using 
libvirt.

The vexpress-a9 doesn't support vga cards, but libvirt adds a video cirrus 
video card when there is a graphics element in the domain xml. This prevents 
the domain from booting.

At the moment, the only workaround I found is to add the following to my xml 
file :
qemu:commandline
  qemu:arg value='-vga'/
  qemu:arg value='none'/
/qemu:commandline

What do you think about adding a none model type for video cards ? I know it 
is a bit strange to declare a video card in order to have none...
I don't know the QEMU driver well, but maybe this could be handled by the 
driver ? i.e. no VGA card when the machine is vexpress-a9.

Regards,

Jean-Baptiste

-- 
Jean-Baptiste ROUAULT
RD Engineer - diateam : Architectes de l'information
Phone : +33 (0)2 98 050 050 Fax : +33 (0)2 98 050 051

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


Re: [libvirt] [PATCH] vmware: make version parsing more robust

2014-06-09 Thread Jean-Baptiste Rouault
On Monday 28 April 2014 13:46:54 Ján Tomko wrote:
 On 04/09/2014 11:59 AM, Jean-Baptiste Rouault wrote:
  Since commit d69415d4, vmware version is parsed from both stdout and
  stderr. This patch makes version parsing work even if there is garbage
  (libvirt debug messages for example) in the command output.
 
 For libvirt's debug messages, we have virLogProbablyLogMessage that can
 check if the message matches libvirt's format.
 
 Should we really ignore all garbage?

Honestly I don't know, but as of today the only garbage I saw there was from 
libvirt. Apart from the version string, I don't think there could be useful 
information in the command output.

Regards,

Jean-Baptiste

-- 
Jean-Baptiste ROUAULT
RD Engineer - diateam : Architectes de l'information
Phone : +33 (0)2 98 050 050 Fax : +33 (0)2 98 050 051

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


[libvirt] [PATCH] build: avoid compiler warning on shadowed name

2014-04-09 Thread Jean-Baptiste Rouault
Introduced in commit d1e55de3.
virstoragetest.c: In function ‘testStorageChain’:
virstoragetest.c:249:10: warning: declaration of ‘abs’ shadows a global
declaration [-Wshadow]
---
 tests/virstoragetest.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
index 74ad15c..bfdee8c 100644
--- a/tests/virstoragetest.c
+++ b/tests/virstoragetest.c
@@ -246,7 +246,7 @@ testStorageChain(const void *args)
 virStorageFileMetadataPtr elt;
 size_t i = 0;
 char *broken = NULL;
-bool abs = !!(data-flags  ABS_START);
+bool isAbs = !!(data-flags  ABS_START);
 
 meta = virStorageFileGetMetadata(data-start, data-format, -1, -1,
  (data-flags  ALLOW_PROBE) != 0);
@@ -292,7 +292,7 @@ testStorageChain(const void *args)
 goto cleanup;
 }
 
-expDirectory = abs ? data-files[i]-expDirectoryAbs
+expDirectory = isAbs ? data-files[i]-expDirectoryAbs
 : data-files[i]-expDirectoryRel;
 if (virAsprintf(expect,
 store:%s\nraw:%s\ndirectory:%s\nother:%d %d %lld %d,
-- 
1.8.5.3

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

[libvirt] [PATCH] vmware: make version parsing more robust

2014-04-09 Thread Jean-Baptiste Rouault
Since commit d69415d4, vmware version is parsed from both stdout and
stderr. This patch makes version parsing work even if there is garbage
(libvirt debug messages for example) in the command output.

Add test data for this case.
---
 src/vmware/vmware_conf.c   | 10 --
 tests/vmwareverdata/workstation-7.0.0-with-garbage.txt |  3 +++
 tests/vmwarevertest.c  |  1 +
 3 files changed, 12 insertions(+), 2 deletions(-)
 create mode 100644 tests/vmwareverdata/workstation-7.0.0-with-garbage.txt

diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c
index 5ff6396..1f6f3bd 100644
--- a/src/vmware/vmware_conf.c
+++ b/src/vmware/vmware_conf.c
@@ -1,7 +1,7 @@
 /*---*/
 /*
  * Copyright (C) 2011-2014 Red Hat, Inc.
- * Copyright 2010, diateam (www.diateam.net)
+ * Copyright (C) 2010-2014, diateam (www.diateam.net)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -241,7 +241,13 @@ vmwareParseVersionStr(int type, const char *verbuf, 
unsigned long *version)
 return -1;
 }
 
-if ((tmp = STRSKIP(verbuf, pattern)) == NULL) {
+if ((tmp = strstr(verbuf, pattern)) == NULL) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(cannot find version pattern \%s\), pattern);
+return -1;
+}
+
+if ((tmp = STRSKIP(tmp, pattern)) == NULL) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(failed to parse %sversion), pattern);
 return -1;
diff --git a/tests/vmwareverdata/workstation-7.0.0-with-garbage.txt 
b/tests/vmwareverdata/workstation-7.0.0-with-garbage.txt
new file mode 100644
index 000..b3c8085
--- /dev/null
+++ b/tests/vmwareverdata/workstation-7.0.0-with-garbage.txt
@@ -0,0 +1,3 @@
+garbage line
+VMware Workstation 7.0.0 build-203739 Release
+garbage line
diff --git a/tests/vmwarevertest.c b/tests/vmwarevertest.c
index 16e48de..24de9e1 100644
--- a/tests/vmwarevertest.c
+++ b/tests/vmwarevertest.c
@@ -88,6 +88,7 @@ mymain(void)
 } while (0)
 
 DO_TEST(ws, workstation-7.0.0, 700);
+DO_TEST(ws, workstation-7.0.0-with-garbage, 700);
 DO_TEST(fusion, fusion-5.0.3, 503);
 
 return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
-- 
1.8.5.3

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


[libvirt] [PATCH] vmware: set the driver version

2014-04-08 Thread Jean-Baptiste Rouault
Since commit 7457cbe8 the vmware driver version isn't set anymore.
---
 src/vmware/vmware_conf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c
index 6aba4f8..5e894a4 100644
--- a/src/vmware/vmware_conf.c
+++ b/src/vmware/vmware_conf.c
@@ -301,6 +301,7 @@ vmwareExtractVersion(struct vmware_driver *driver)
 if (vmwareParseVersionStr(driver-type, outbuf, version)  0)
 goto cleanup;
 
+driver-version = version;
 ret = 0;
 
  cleanup:
-- 
1.8.5.3

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


[libvirt] [PATCH] docs: cgroups: fix typo about LXC cgroups

2014-03-27 Thread Jean-Baptiste Rouault
---
 docs/cgroups.html.in | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/docs/cgroups.html.in b/docs/cgroups.html.in
index f7c2450..33de453 100644
--- a/docs/cgroups.html.in
+++ b/docs/cgroups.html.in
@@ -33,9 +33,9 @@
 
 p
   The LXC driver is capable of using the codecpuset/code,
-  codecpu/code, codecpuset/code, codefreezer/code,
+  codecpu/code, codecpuacct/code, codefreezer/code,
   codememory/code, codeblkio/code and codedevices/code
-  controllers. The codecpuset/code, codedevices/code
+  controllers. The codecpuacct/code, codedevices/code
   and codememory/code controllers are compulsory. Without
   them mounted, no containers can be started. If any of the
   other controllers are not mounted, the resource management APIs
-- 
1.8.5.3

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


Re: [libvirt] [PATCHv6 0/5] Handling of undefine and redefine snapshots with VirtualBox 4.2

2014-02-10 Thread Jean-Baptiste Rouault
Hi,

Is there any chance that this serie be reviewed before the next freeze ?
The v1 was sent back in June and since then we need to maintain our own custom  
package with our patches in it because we need this feature. We're a very 
small team and it's quite time consuming.

Regards,

Jean-Baptiste

On Thursday 23 January 2014 10:28:28 Manuel VIVES wrote:
 Hi,
 This is a serie of patches in order to support undefining and redefining
 snapshots with VirtualBox 4.2.
 
 The serie of patches is rather big, and adds among other things some
 utility functions unrelated to VirtualBox in patches 1  2.
 The code review could be done in several parts: e.g. patches 1  2
 separately to validate the utility functions.
 
 The VirtualBox API provides only high level operations to manipulate
 snapshots, so it not possible to support flags like
 VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE and
 VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY with only API calls.
 Following an IRC talk with Eric Blake, the decision was taken to emulate
 these behaviours by manipulating directly the .vbox XML files.
 
 The first two patches are some util methods for handling regexp and strings
 that will be used after.
 
 The third patch brings more details in the snapshot XML returned by
 libvirt. We will need those modifications in order to redefine the
 snapshots.
 
 The fourth patch brings the support of the
 VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE and VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT
 flags in virDomainSnapshotCreateXML.
 
 The fifth and last patch brings the support of the
 VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY
 flag in virDomainSnapshotDelete.
 
 The patches are only tested with Virtualbox 4.2 but the code is
 compliant with Virtualbox 4.3 API.
 
 Regards,
 Manuel VIVES
 
 v6:
 * Rebased because of a massive change in vbox_tmpl.c due to changes in
 the handling of different versions of VirtualBox
 
 v5:
 * The patches are modified according to a first review by Laine Stump:
 * renamed virSearchUuid to virSearchRegex and moved it from
 viruuid.{c,h} to virstring.{c,h}.
 * Various fixes.
 
 V4:
 * The code is compliant with Virtualbox 4.3 API
 * Some minor modifications in order to satisfy make syntax-check
 
 V3:
 * Use of STREQ_NULLABLE instead of STREQ in one case
 * Fix the method for finding uuids according to Ján Tomko review
 
 V2:
 * Fix a licence problem with the method for string replacement
 
 
 Manuel VIVES (5):
   virstring.h/c: Util method for finding regexp patterns in some
 strings
   virstring.h/c: Util method for making some find and replace in
 strings
   vbox_tmpl.c: Better XML description for snapshots
   vbox_tmpl.c: Patch for redefining snapshots
   vbox_tmpl.c: Add methods for undefining snapshots
 
  po/POTFILES.in   |1 +
  src/libvirt_private.syms |2 +
  src/util/virstring.c |  163 +++-
  src/util/virstring.h |4 +
  src/vbox/vbox_tmpl.c | 2346
 ++ 5 files changed, 2346
 insertions(+), 170 deletions(-)

-- 
Jean-Baptiste ROUAULT
RD Engineer - diateam : Architectes de l'information
Phone : +33 (0)2 98 050 050 Fax : +33 (0)2 98 050 051

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

Re: [libvirt] [PATCH] vbox: add support for v4.2.20+ and v4.3.4+

2013-12-31 Thread Jean-Baptiste Rouault
On Monday 30 December 2013 11:26:08 Ryota Ozaki wrote:
 On Mon, Dec 30, 2013 at 5:55 PM, Jean-Baptiste Rouault
 
 jean-baptiste.roua...@diateam.net wrote:
  On Sunday 29 December 2013 14:44:10 Ryota Ozaki wrote:
  On Wed, Dec 25, 2013 at 12:47 AM, Jean-Baptiste Rouault
  
  jean-baptiste.roua...@diateam.net wrote:
   While working on adding virDomain*Stats support to the vbox driver, we
   found bugs in the VirtualBox API C bindings. These bugs have been
   fixed in versions 4.2.20 and 4.3.4.
   However, the changes in the C bindings are incompatible with the
   vbox_CAPI_v4_2.h and vbox_CAPI_v4_3.h files which are bundled in
   libvirt source code. This is why the following patch adds
   vbox_CAPI_v4_2_20.h and vbox_CAPI_v4_3_4.h.
   
   We tried to keep compatibility with older VirtualBox 4.2.x and 4.3.x
   releases so we added a SPECIAL_VERSION identifier to conditionnaly
   include the right header. I'm not really pleased with this
   SPECIAL_VERSION identifier, maybe we could instead increase the
   precision of VBOX_API_VERSION, for example 4002 would become
   4002000. This would permit us to select the right header based on the
   VBOX_API_VERSION only, what do you think ?
  
  Can we use VBOX_XPCOMC_VERSION instead of adding a new flag?
  The version has been bumped up when the incompatibility is introduced.
  
ozaki-r
  
  The problem is that VBOX_XPCOMC_VERSION is defined in the vbox_CAPI_v*.h
  headers and we need a flag to choose which header we have to include.
 
 Oops. You're right.
 
 Well, one other idea is to include each vbox_CAPI_X_Y.h in
 the corresponding vbox_VX_Y.c. That's rather straightforward
 for me than including vbox_CAPI_*.h in vbox_tmpl.c according to
 VBOX_API_VERSION.
 
   ozaki-r

This would indeed solve the problem for header inclusion. But what about 
future code using the new API ? Will it have to check both VBOX_API_VERSION 
and VBOX_XPCOMC_VERSION ?
Wouldn't it be simpler if VBOX_API_VERSION was more precise ? e.g 4003004

-- 
Jean-Baptiste ROUAULT
RD Engineer - diateam : Architectes de l'information
Phone : +33 (0)2 98 050 050 Fax : +33 (0)2 98 050 051

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


Re: [libvirt] [PATCH] vbox: add support for v4.2.20+ and v4.3.4+

2013-12-30 Thread Jean-Baptiste Rouault
On Sunday 29 December 2013 14:44:10 Ryota Ozaki wrote:
 On Wed, Dec 25, 2013 at 12:47 AM, Jean-Baptiste Rouault
 
 jean-baptiste.roua...@diateam.net wrote:
  While working on adding virDomain*Stats support to the vbox driver, we
  found bugs in the VirtualBox API C bindings. These bugs have been fixed
  in versions 4.2.20 and 4.3.4.
  However, the changes in the C bindings are incompatible with the
  vbox_CAPI_v4_2.h and vbox_CAPI_v4_3.h files which are bundled in libvirt
  source code. This is why the following patch adds vbox_CAPI_v4_2_20.h
  and vbox_CAPI_v4_3_4.h.
  
  We tried to keep compatibility with older VirtualBox 4.2.x and 4.3.x
  releases so we added a SPECIAL_VERSION identifier to conditionnaly
  include the right header. I'm not really pleased with this
  SPECIAL_VERSION identifier, maybe we could instead increase the
  precision of VBOX_API_VERSION, for example 4002 would become 4002000.
  This would permit us to select the right header based on the
  VBOX_API_VERSION only, what do you think ?
 
 Can we use VBOX_XPCOMC_VERSION instead of adding a new flag?
 The version has been bumped up when the incompatibility is introduced.
 
   ozaki-r

The problem is that VBOX_XPCOMC_VERSION is defined in the vbox_CAPI_v*.h 
headers and we need a flag to choose which header we have to include.

-- 
Jean-Baptiste ROUAULT
RD Engineer - diateam : Architectes de l'information
Phone : +33 (0)2 98 050 050 Fax : +33 (0)2 98 050 051

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


[libvirt] [PATCH] vbox: add support for v4.2.20+ and v4.3.4+

2013-12-24 Thread Jean-Baptiste Rouault
While working on adding virDomain*Stats support to the vbox driver, we
found bugs in the VirtualBox API C bindings. These bugs have been fixed
in versions 4.2.20 and 4.3.4.
However, the changes in the C bindings are incompatible with the 
vbox_CAPI_v4_2.h
and vbox_CAPI_v4_3.h files which are bundled in libvirt source code. This is 
why the
following patch adds vbox_CAPI_v4_2_20.h and vbox_CAPI_v4_3_4.h.

We tried to keep compatibility with older VirtualBox 4.2.x and 4.3.x releases 
so we
added a SPECIAL_VERSION identifier to conditionnaly include the right header.
I'm not really pleased with this SPECIAL_VERSION identifier, maybe we could 
instead
increase the precision of VBOX_API_VERSION, for example 4002 would become 
4002000.
This would permit us to select the right header based on the VBOX_API_VERSION 
only, what
do you think ?

Jean-Baptiste Rouault (1):
  vbox: add support for v4.2.20+ and v4.3.4+

 src/Makefile.am  | 4 +-
 src/vbox/vbox_CAPI_v4_2_20.h |  9001 +++
 src/vbox/vbox_CAPI_v4_3_4.h  | 10321 +
 src/vbox/vbox_V2_2.c | 1 +
 src/vbox/vbox_V3_0.c | 1 +
 src/vbox/vbox_V3_1.c | 1 +
 src/vbox/vbox_V3_2.c | 1 +
 src/vbox/vbox_V4_0.c | 1 +
 src/vbox/vbox_V4_1.c | 1 +
 src/vbox/vbox_V4_2.c | 1 +
 src/vbox/vbox_V4_2_20.c  |14 +
 src/vbox/vbox_V4_3.c | 1 +
 src/vbox/vbox_V4_3_4.c   |14 +
 src/vbox/vbox_driver.c   |20 +-
 src/vbox/vbox_tmpl.c |12 +-
 15 files changed, 19389 insertions(+), 5 deletions(-)
 create mode 100644 src/vbox/vbox_CAPI_v4_2_20.h
 create mode 100644 src/vbox/vbox_CAPI_v4_3_4.h
 create mode 100644 src/vbox/vbox_V4_2_20.c
 create mode 100644 src/vbox/vbox_V4_3_4.c

-- 
1.8.5.1

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


Re: [libvirt] [PATCH] vbox: add support for v4.2.20+ and v4.3.4+

2013-12-24 Thread Jean-Baptiste Rouault
On Tuesday 24 December 2013 17:00:19 Eric Blake wrote:
 On 12/24/2013 08:47 AM, Jean-Baptiste Rouault wrote:
  While working on adding virDomain*Stats support to the vbox driver, we
  found bugs in the VirtualBox API C bindings. These bugs have been fixed
  in versions 4.2.20 and 4.3.4.
  However, the changes in the C bindings are incompatible with the
  vbox_CAPI_v4_2.h and vbox_CAPI_v4_3.h files which are bundled in libvirt
  source code. This is why the following patch adds vbox_CAPI_v4_2_20.h
  and vbox_CAPI_v4_3_4.h.
  
  We tried to keep compatibility with older VirtualBox 4.2.x and 4.3.x
  releases so we added a SPECIAL_VERSION identifier to conditionnaly
  include the right header. I'm not really pleased with this
  SPECIAL_VERSION identifier, maybe we could instead increase the
  precision of VBOX_API_VERSION, for example 4002 would become 4002000.
  This would permit us to select the right header based on the
  VBOX_API_VERSION only, what do you think ?
  
  Jean-Baptiste Rouault (1):
vbox: add support for v4.2.20+ and v4.3.4+
   
   src/Makefile.am  | 4 +-
   src/vbox/vbox_CAPI_v4_2_20.h |  9001 +++
   src/vbox/vbox_CAPI_v4_3_4.h  | 10321
   +
 
 This patch is HUGE (620k, so the moderation queue is currently holding
 it as oversized, compared to the normal 150k limit).  Is there any way
 to break it into smaller pieces, or compress it before sending to the
 list, or merely point to an external repo containing the patch, so that
 we aren't chewing up lots of bandwidth on mostly mechanical code?

The patch is available at http://git-lab.diateam.net/cots/libvirt.git/
The branch is named vbox-4.2.20-4.3.4-support

Regards,

-- 
Jean-Baptiste ROUAULT
RD Engineer - diateam : Architectes de l'information
Phone : +33 (0)2 98 050 050 Fax : +33 (0)2 98 050 051

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


Re: [libvirt] VirtualBox 4.2 Support

2013-06-12 Thread Jean-Baptiste Rouault
On Wednesday 12 June 2013 04:15:53 Dead Horse wrote:
 Last activity I could find on this subject was
 here: https://www.redhat.com/archives/libvir-list/2013-May/msg01610.html
 Further activity here as well:
 https://www.redhat.com/archives/libvir-list/2013-June/msg00379.html
 
 
 I am willing to volunteer systems here to test libvirt+virtualbox 4.2
 functionality.
 
 - DHC
 
 
 On Tue, Jun 11, 2013 at 1:12 PM, Dead Horse
 
 deadhorseconsult...@gmail.comwrote:
  Is there any active development to support VirtualBox 4.2 under libvirt?
  
  - DHC

Hello,

Patches adding support for VirtualBox 4.2 were pushed to the libvirt git 
repository a few days ago.
Instructions for cloning the repository and building libvirt are available on 
the libvirt website.

Regards

-- 
Jean-Baptiste ROUAULT
RD Engineer - diateam : Architectes de l'information
Phone : +33 (0)2 98 050 050 Fax : +33 (0)2 98 050 051

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


[libvirt] [PATCH 0/2] vmx: handle shared folders

2012-07-11 Thread Jean-Baptiste Rouault
The following patches add support for shared folders
for VMware domains

Jean-Baptiste Rouault (2):
  vmx: handle shared folders formatting
  vmx: handle shared folders parsing

 src/vmx/vmx.c  |  193 +++-
 src/vmx/vmx.h  |5 +
 tests/vmx2xmldata/vmx2xml-sharedfolder.vmx |9 ++
 tests/vmx2xmldata/vmx2xml-sharedfolder.xml |   22 
 tests/vmx2xmltest.c|2 +
 tests/xml2vmxdata/xml2vmx-sharedfolder.vmx |   18 +++
 tests/xml2vmxdata/xml2vmx-sharedfolder.xml |   14 ++
 tests/xml2vmxtest.c|2 +
 8 files changed, 263 insertions(+), 2 deletions(-)
 create mode 100644 tests/vmx2xmldata/vmx2xml-sharedfolder.vmx
 create mode 100644 tests/vmx2xmldata/vmx2xml-sharedfolder.xml
 create mode 100644 tests/xml2vmxdata/xml2vmx-sharedfolder.vmx
 create mode 100644 tests/xml2vmxdata/xml2vmx-sharedfolder.xml

-- 
1.7.10.4

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


[libvirt] [PATCH 1/2] vmx: handle shared folders formatting

2012-07-11 Thread Jean-Baptiste Rouault
This patch adds support for generating vmx files with
shared folders enabled.

Update test suite accordingly.
---
 src/vmx/vmx.c  |   59 +++-
 src/vmx/vmx.h  |3 ++
 tests/xml2vmxdata/xml2vmx-sharedfolder.vmx |   18 +
 tests/xml2vmxdata/xml2vmx-sharedfolder.xml |   14 +++
 tests/xml2vmxtest.c|2 +
 5 files changed, 95 insertions(+), 1 deletion(-)
 create mode 100644 tests/xml2vmxdata/xml2vmx-sharedfolder.vmx
 create mode 100644 tests/xml2vmxdata/xml2vmx-sharedfolder.xml

diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 3de7062..8a26f8c 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -262,6 +262,29 @@ def-disks[0]...
 
 
 

+## filesystems 
#
+
+isolation.tools.hgfs.disable = false 
 # defaults to true
+
+def-nfss = 1 =   sharedFolder.maxNum = 1  
 # must match the number of shared folders
+
+sharedFolder[0..n] - filesystem
+
+def-fss[0]...=   sharedFolder0.present = true 
 # defaults to false
+sharedFolder0.enabled = true 
 # defaults to false
+sharedFolder0.expiration = never 
 # defaults to never
+sharedFolder0.readAccess = true  
 # defaults to false
+-type = _FS_TYPE_MOUNT
+-fsdriver
+-accessmode
+-wrpolicy
+-src = value   =   sharedFolder0.hostPath = value 
 # defaults to ?
+-dst = value   =   sharedFolder0.guestName = value
+-readonly = readonly   =   sharedFolder0.writeAccess = value  
 # true - readonly = 0, false - readonly = 1
+
+
+
+
 ## nets 

 
 ethernet[0..3] - controller
@@ -3142,7 +3165,16 @@ virVMXFormatConfig(virVMXContext *ctx, virCapsPtr caps, 
virDomainDefPtr def,
 }
 
 /* def:fss */
-/* FIXME */
+if (def-nfss  0) {
+virBufferAddLit(buffer, isolation.tools.hgfs.disable = \false\\n);
+virBufferAsprintf(buffer, sharedFolder.maxNum = \%d\\n, 
def-nfss);
+}
+
+for (i = 0; i  def-nfss; ++i) {
+if (virVMXFormatFileSystem(def-fss[i], i, buffer)  0) {
+goto cleanup;
+}
+}
 
 /* def:nets */
 for (i = 0; i  def-nnets; ++i) {
@@ -3496,6 +3528,31 @@ virVMXFormatFloppy(virVMXContext *ctx, 
virDomainDiskDefPtr def,
 
 
 int
+virVMXFormatFileSystem(virDomainFSDefPtr def, int index, virBufferPtr buffer)
+{
+if (def-type != VIR_DOMAIN_FS_TYPE_MOUNT) {
+VMX_ERROR(VIR_ERR_CONFIG_UNSUPPORTED,
+  _(Only '%s' filesystem type is supported),
+  virDomainFSTypeToString(VIR_DOMAIN_FS_TYPE_MOUNT));
+return -1;
+}
+
+virBufferAsprintf(buffer, sharedFolder%d.present = \true\\n, index);
+virBufferAsprintf(buffer, sharedFolder%d.enabled = \true\\n, index);
+virBufferAsprintf(buffer, sharedFolder%d.readAccess = \true\\n, index);
+virBufferAsprintf(buffer, sharedFolder%d.writeAccess = \%s\\n, index,
+  def-readonly ? false : true);
+virBufferAsprintf(buffer, sharedFolder%d.hostPath = \%s\\n, index,
+  def-src);
+virBufferAsprintf(buffer, sharedFolder%d.guestName = \%s\\n, index,
+  def-dst);
+
+return 0;
+}
+
+
+
+int
 virVMXFormatEthernet(virDomainNetDefPtr def, int controller,
  virBufferPtr buffer)
 {
diff --git a/src/vmx/vmx.h b/src/vmx/vmx.h
index 4d54660..656aafa 100644
--- a/src/vmx/vmx.h
+++ b/src/vmx/vmx.h
@@ -120,6 +120,9 @@ int virVMXFormatCDROM(virVMXContext *ctx, 
virDomainDiskDefPtr def,
 int virVMXFormatFloppy(virVMXContext *ctx, virDomainDiskDefPtr def,
virBufferPtr buffer, bool floppy_present[2]);
 
+int virVMXFormatFileSystem(virDomainFSDefPtr def, int index,
+   virBufferPtr buffer);
+
 int virVMXFormatEthernet(virDomainNetDefPtr def, int controller,
  virBufferPtr buffer);
 
diff --git a/tests/xml2vmxdata/xml2vmx-sharedfolder.vmx 
b/tests/xml2vmxdata/xml2vmx-sharedfolder.vmx
new file mode 100644
index 000..15a322a
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-sharedfolder.vmx
@@ -0,0 +1,18 @@
+.encoding = UTF-8
+config.version = 8
+virtualHW.version = 4
+guestOS = other
+uuid.bios = 56 4d 9b ef ac d9 b4 e0-c8 f0 ae a8 b9 10 35 15
+displayName = sharedFolder
+memsize = 4
+numvcpus = 1
+floppy0.present = false
+floppy1.present = false
+isolation.tools.hgfs.disable = false
+sharedFolder.maxNum = 1
+sharedFolder0.present = 

Re: [libvirt] [RFC] Allowing promiscuous mode for domains network interfaces

2012-07-05 Thread Jean-Baptiste Rouault
On Monday 02 July 2012 19:14:04 Eric Blake wrote:
 On 07/02/2012 09:28 AM, Jean-Baptiste Rouault wrote:
  Hi all,
  
  By default, OpenVZ and VirtualBox ( 4.0.x) filter network packets by MAC
  addresses : only broadcast, multicast and packets directly targeted to
  VMs are transmitted.
  This behaviour prevents from using promiscuous mode inside domains.
  
  I'd like to write some patches to disable these filters from libvirt.
  Would it be ok to modify OpenVZ and VirtualBox drivers so that they
  disable the filters by default ?
  
  If this is not acceptable, what about making it configurable through
  domains' XML ?
 
 It sounds like exposing this through the domain XML would be useful to
 other hypervisors, and certainly something that I would rather have
 configurable per-guest instead of hard-coded to one default or another.
  We might declare that if the XML element is not present then it is up
 to hypervisor defaults whether the interface is promiscuous, to allow
 for back-compat, while still allowing the user to explicitly select
 narrow or promiscuous with new libvirt.

Ok, so what about adding a promiscuouspolicy attribute to the interface 
tag ?

There are currently 3 possible values with VirtualBox :
- Deny
- AllowNetwork : allow promiscuous mode but restrict its scope to the internal 
network
- AllowAll

So we could create a virDomainNetPromiscuousPolicy enum with these 3 values 
for a start.

Regards

-- 
Jean-Baptiste ROUAULT
Ingénieur RD - diateam : Architectes de l'information
Phone : +33 (0)2 98 050 050 Fax : +33 (0)2 98 050 051

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


[libvirt] [RFC] Allowing promiscuous mode for domains network interfaces

2012-07-02 Thread Jean-Baptiste Rouault
Hi all,

By default, OpenVZ and VirtualBox ( 4.0.x) filter network packets by MAC 
addresses : only broadcast, multicast and packets directly targeted to VMs are 
transmitted.
This behaviour prevents from using promiscuous mode inside domains.

I'd like to write some patches to disable these filters from libvirt.
Would it be ok to modify OpenVZ and VirtualBox drivers so that they disable 
the filters by default ?

If this is not acceptable, what about making it configurable through domains' 
XML ?

Regards,
Jean-Baptiste

-- 
Jean-Baptiste ROUAULT
Ingénieur RD - diateam : Architectes de l'information
Phone : +33 (0)2 98 050 050 Fax : +33 (0)2 98 050 051

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

Re: [libvirt] [Patch v2] vmware: detect when a domain was shut down from the inside

2012-07-02 Thread Jean-Baptiste Rouault
On Monday 02 April 2012 15:59:32 Jean-Baptiste Rouault wrote:
 This patch adds an internal function vmwareUpdateVMStatus to
 update the real state of the domain. This function is used in
 various places in the driver, in particular to detect when
 the domain has been shut down by the user with the halt
 command.

Hi,

Bumping the thread because it seems that it was forgotten.

Regards,
Jean-Baptiste

-- 
Jean-Baptiste ROUAULT
Ingénieur RD - diateam : Architectes de l'information
Phone : +33 (0)2 98 050 050 Fax : +33 (0)2 98 050 051

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


Re: [libvirt] [PATCH] vbox: Fix passing an empty IMedium* array to IMachine::Delete

2012-04-23 Thread Jean-Baptiste Rouault
On Sunday 22 April 2012 10:35:59 Matthias Bolte wrote:
 vboxArray is not castable to a COM item type. vboxArray is a
 wrapper around the XPCOM and MSCOM specific array handling.
 
 In this case we can avoid passing NULL as an empty array to
 IMachine::Delete by passing a dummy IMedium* array with a single
 NULL item.
 ---
 
 Jean-Baptiste, I can not reproduce the assertion you mentioned, or
 I don't know where to look for it. So could you verify that is patch
 avoids this assertion?
 
  src/vbox/vbox_tmpl.c |9 -
  1 files changed, 4 insertions(+), 5 deletions(-)
 
 diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
 index 57c18a4..4b0ee2e 100644
 --- a/src/vbox/vbox_tmpl.c
 +++ b/src/vbox/vbox_tmpl.c
 @@ -5294,11 +5294,10 @@ vboxDomainUndefineFlags(virDomainPtr dom, unsigned
 int flags)
 
  ((IMachine_Delete)machine-vtbl-Delete)(machine, safeArray,
 progress); # else
 -union {
 -vboxArray array;
 -IMedium *medium;
 -} u = { .array = VBOX_ARRAY_INITIALIZER };
 -machine-vtbl-Delete(machine, 0, u.medium, progress);
 +/* XPCOM doesn't like NULL as an array, even when the array size
 is 0. + * Instead pass it a dummy array to avoid passing NULL. */
 +IMedium *array[] = { NULL };
 +machine-vtbl-Delete(machine, 0, array, progress);
  # endif
  if (progress != NULL) {
  progress-vtbl-WaitForCompletion(progress, -1);

The patch is good, I don't get the assertion anymore.

-- 
Jean-Baptiste ROUAULT
Ingénieur RD - diateam : Architectes de l'information
Phone : +33 (0)2 98 050 050 Fax : +33 (0)2 98 050 051

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


[libvirt] Making the Thread-safety issues with vbox driver ?

2012-04-19 Thread Jean-Baptiste Rouault
On Wednesday 04 April 2012 17:56:12 Jean-Baptiste Rouault wrote:
 On Monday 16 January 2012 11:34:53 Matthias Bolte wrote:
  Okay, without looking deeper into this here are some ideas:
  
  The XPCOM API libvirt uses might not be threadsafe, or needs to be
  initialized for every thread that wants to use it. Currently its only
  initialized for the thread that opens the driver. I know that this is
  the case on Windows were VirtualBox uses MSCOM for its API and you
  need to call CoInitialize on every thread. This is currently not done
  for the MSCOM glue in libvirt, so I know that on Windows the
  VirtualBox driver is not threadsafe currently. Also I didn't look into
  a solution for this yet. Maybe we need a thread local variable that
  holds whether (MS/XP)COM was already initialized for this thread and
  add a check to every driver function to initialize it when needed.
  
  Did you try to open a connection for each thread instead of trying to
  share one? If that works reliable it might indicate that there is an
  VirtualBox API initialization problem.
 
 I tried today with one connection for each thread and it works.
 
 I changed the vbox driver so that the pfnComInitialize function is called
 only when the first connection is opened : it breaks the test, even with
 one connection per thread.
 
 I guess we'll have to use a thread local variable as you suggested, unless
 someone has a better idea to handle this problem.

Hi,

I looked deeper into these thread-safety issues, once a new connection is 
opened for each thread, everything works well.
However, opening and closing connections isn't thread-safe at all for two 
reasons :

- VirtualBox C bindings initialization and uninitialization functions aren't 
thread-safe. I talked about it with upstream on IRC and they are probably not 
going to fix it, but would accept a patch fixing the issue. I'm going to 
contact 
upstream again to get some advices so I can write a patch.

- In the libvirt vbox driver, for each new connection, modification of the 
global variable g_pVBoxGlobalData isn't protected (see line 1040 of 
vbox_tmpl.c). 

First of all, is it really necessary to replace it on each new connection, or 
would it be ok to initialize it only when the first connection is opened ?

A global mutex is needed in the vbox driver to protect access to 
g_pVBoxGlobalData, the vboxRegister() function seems to be the best place to 
initialize such a mutex unless there is another entry point to do this ?

-- 
Jean-Baptiste ROUAULT
Ingénieur RD - diateam : Architectes de l'information
Phone : +33 (0)2 98 050 050 Fax : +33 (0)2 98 050 051

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

Re: [libvirt] Making the Thread-safety issues with vbox driver ?

2012-04-19 Thread Jean-Baptiste Rouault
On Thursday 19 April 2012 16:23:19 Matthias Bolte wrote:
 Am 19. April 2012 12:51 schrieb Jean-Baptiste Rouault
  
  A global mutex is needed in the vbox driver to protect access to
  g_pVBoxGlobalData, the vboxRegister() function seems to be the best place
  to initialize such a mutex unless there is another entry point to do
  this ?
 
 Such a mutex doesn't help.
 
 Looking at g_pVBoxGlobalData tells me that we need to get rid of it in
 its current form for different reasons. The major reason is that it
 contains connection specific data such as the conn and domainEvents
 members. This means when you open a new connection you break all other
 open connections because connection specific data is overwritten. We
 need to redesign this.
 
 A major reason for the existence of g_pVBoxGlobalData is given in line
 209 of vbox_tmpl.c: g_pVBoxGlobalData needs to be global because event
 callbacks won't work otherwise. Actually that's not true. Who ever did
 the original implementation of this was not aware of how COM (MS and
 XP variants) works.
 
 There is a vboxAllocCallbackObj function that creates an
 IVirtualBoxCallback COM object. The first member in a COM objects is a
 pointer to its vtbl that contains pointers to all the methods that can
 be called on it. After this vtbl the COM object contains its private
 data members, this aspect is not used in the current implementation.
 
 So we could just allocate a bigger object and put the data that
 belongs to the IVirtualBoxCallback implementation into this additional
 memory. This includes at least vboxCallBackRefCount and domainEvents
 that are currently located in g_pVBoxGlobalData.
 
 The only two members of g_pVBoxGlobalData that can stay global are
 caps and pFuncs, all other members are specific to a connection and
 cannot be global.

I'm not familiar with COM, but if all this connection-specific code can be 
moved out it's nice.

 Are you referring to data-pFuncs-pfnComInitialize and
 data-pFuncs-pfnComUninitialize when you say VirtualBox C bindings
 initialization and uninitialization functions? As those are used to
 create connection specific objects we cannot move them out of
 vboxOpen/vboxClose. If they are not thread-safe than we need to put a
 global mutex around these calls.

Yes these two functions aren't thread-safe, it is even worse than that.
They are located in src/VBox/Main/cbinding/VBoxXPCOMC.cpp in the VirtualBox 
source code. There are 4 static pointers which are replaced at each 
pfnComInitialize call, and released (via the NS_RELEASE macro) in 
pfnComUninitialize.

These accesses aren't protected at all, but what is worse is that when you 
call pfnComUninitialize, the pointers to the IVirtualBox, ISession and 
nsIEventQueue are released. So if you open multiple connections, then close 
one of them, these objects are deleted and your last opened connection is 
broken.

As you said, a global mutex is needed around these calls, but I think we 
should also use the VBOX_ADDREF() macro on the IVirtualBox, ISession and 
nsIEventQueue objects after pfnComInitialize, and VBOX_RELEASE() after 
pfnComUninitialize.

-- 
Jean-Baptiste ROUAULT
Ingénieur RD - diateam : Architectes de l'information
Phone : +33 (0)2 98 050 050 Fax : +33 (0)2 98 050 051

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

[libvirt] [PATCH] vbox: avoid provoking assertions in VBoxSVC

2012-04-13 Thread Jean-Baptiste Rouault
Passing a NULL pointer to IMachine::delete virtualbox API
causes VBoxSVC to raise an assertion. This patch passes
an empty array instead.
---
 src/vbox/vbox_tmpl.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 68e3b05..be25828 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -5294,7 +5294,8 @@ vboxDomainUndefineFlags(virDomainPtr dom, unsigned int 
flags)
 
 ((IMachine_Delete)machine-vtbl-Delete)(machine, safeArray, 
progress);
 # else
-machine-vtbl-Delete(machine, 0, NULL, progress);
+vboxArray array = VBOX_ARRAY_INITIALIZER;
+machine-vtbl-Delete(machine, 0, (IMedium**)array, progress);
 # endif
 if (progress != NULL) {
 progress-vtbl-WaitForCompletion(progress, -1);
-- 
1.7.9.1

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


[libvirt] [Patch v2] vmware: detect when a domain was shut down from the inside

2012-04-02 Thread Jean-Baptiste Rouault
This patch adds an internal function vmwareUpdateVMStatus to
update the real state of the domain. This function is used in
various places in the driver, in particular to detect when
the domain has been shut down by the user with the halt
command.
---
v2:
 - Replace internal function vmwareGetVMStatus by vmwareUpdateVMStatus
 - Improve vmrun list output parsing
 - variable initialization and coding-style fixes
 
 src/vmware/vmware_driver.c |   95 
 1 files changed, 95 insertions(+), 0 deletions(-)

diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index 8f9d922..53e28e7 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -28,6 +28,7 @@
 #include datatypes.h
 #include virfile.h
 #include memory.h
+#include util.h
 #include uuid.h
 #include command.h
 #include vmx.h
@@ -181,6 +182,64 @@ vmwareGetVersion(virConnectPtr conn, unsigned long 
*version)
 }
 
 static int
+vmwareUpdateVMStatus(struct vmware_driver *driver, virDomainObjPtr vm)
+{
+virCommandPtr cmd;
+char *outbuf = NULL;
+char *vmxAbsolutePath = NULL;
+char *parsedVmxPath = NULL;
+char *str;
+char *saveptr = NULL;
+bool found = false;
+int oldState = virDomainObjGetState(vm, NULL);
+int newState;
+int ret = -1;
+
+cmd = virCommandNewArgList(VMRUN, -T, vmw_types[driver-type],
+   list, NULL);
+virCommandSetOutputBuffer(cmd, outbuf);
+if (virCommandRun(cmd, NULL)  0)
+goto cleanup;
+
+if (virFileResolveAllLinks(((vmwareDomainPtr) vm-privateData)-vmxPath,
+   vmxAbsolutePath)  0)
+goto cleanup;
+
+for(str = outbuf ; (parsedVmxPath = strtok_r(str, \n, saveptr)) != NULL;
+str = NULL) {
+
+if (parsedVmxPath[0] != '/')
+continue;
+
+if (STREQ(parsedVmxPath, vmxAbsolutePath)) {
+found = true;
+/* If the vmx path is in the output, the domain is running or
+ * is paused but we have no way to detect if it is paused or not. 
*/
+if (oldState == VIR_DOMAIN_PAUSED)
+newState = oldState;
+else
+newState = VIR_DOMAIN_RUNNING;
+break;
+}
+}
+
+if (!found) {
+vm-def-id = -1;
+newState = VIR_DOMAIN_SHUTOFF;
+}
+
+virDomainObjSetState(vm, newState, 0);
+
+ret = 0;
+
+cleanup:
+virCommandFree(cmd);
+VIR_FREE(outbuf);
+VIR_FREE(vmxAbsolutePath);
+return ret;
+}
+
+static int
 vmwareStopVM(struct vmware_driver *driver,
  virDomainObjPtr vm,
  virDomainShutoffReason reason)
@@ -331,6 +390,9 @@ vmwareDomainShutdownFlags(virDomainPtr dom,
 goto cleanup;
 }
 
+if (vmwareUpdateVMStatus(driver, vm)  0)
+goto cleanup;
+
 if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_RUNNING) {
 vmwareError(VIR_ERR_INTERNAL_ERROR, %s,
 _(domain is not in running state));
@@ -485,6 +547,8 @@ vmwareDomainReboot(virDomainPtr dom, unsigned int flags)
 vmwareSetSentinal(cmd, vmw_types[driver-type]);
 vmwareSetSentinal(cmd, vmxPath);
 
+if (vmwareUpdateVMStatus(driver, vm)  0)
+goto cleanup;
 
 if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_RUNNING) {
 vmwareError(VIR_ERR_INTERNAL_ERROR, %s,
@@ -596,6 +660,9 @@ vmwareDomainCreateWithFlags(virDomainPtr dom,
 goto cleanup;
 }
 
+if (vmwareUpdateVMStatus(driver, vm)  0)
+goto cleanup;
+
 if (virDomainObjIsActive(vm)) {
 vmwareError(VIR_ERR_OPERATION_INVALID,
 %s, _(Domain is already running));
@@ -645,6 +712,9 @@ vmwareDomainUndefineFlags(virDomainPtr dom,
 goto cleanup;
 }
 
+if (vmwareUpdateVMStatus(driver, vm)  0)
+goto cleanup;
+
 if (virDomainObjIsActive(vm)) {
 vm-persistent = 0;
 } else {
@@ -874,6 +944,21 @@ vmwareDomainXMLFromNative(virConnectPtr conn, const char 
*nativeFormat,
 return xml;
 }
 
+static void vmwareDomainObjListUpdateDomain(void *payload, const void *name 
ATTRIBUTE_UNUSED, void *data)
+{
+struct vmware_driver *driver = data;
+virDomainObjPtr vm = payload;
+virDomainObjLock(vm);
+vmwareUpdateVMStatus(driver, vm);
+virDomainObjUnlock(vm);
+}
+
+static void
+vmwareDomainObjListUpdateAll(virDomainObjListPtr doms, struct vmware_driver 
*driver)
+{
+virHashForEach(doms-objs, vmwareDomainObjListUpdateDomain, driver);
+}
+
 static int
 vmwareNumDefinedDomains(virConnectPtr conn)
 {
@@ -881,6 +966,7 @@ vmwareNumDefinedDomains(virConnectPtr conn)
 int n;
 
 vmwareDriverLock(driver);
+vmwareDomainObjListUpdateAll(driver-domains, driver);
 n = virDomainObjListNumOfDomains(driver-domains, 0);
 vmwareDriverUnlock(driver);
 
@@ -894,6 +980,7 @@ vmwareNumDomains(virConnectPtr conn)
 int n;
 
 vmwareDriverLock(driver);
+vmwareDomainObjListUpdateAll(driver-domains, 

Re: [libvirt] [PATCH] vmware: detect when a domain was shut down from the inside

2012-03-13 Thread Jean-Baptiste Rouault
On Friday 03 February 2012 09:42:29 Matthias Bolte wrote: 
 You changed all lifecycle functions not to rely on possible stale
 information, but you missed to update the cached state information in
 the virDomainObj list resulting in virsh list giving wrong output and
 possibly listing VMs as active that aren't active anymore.
 
 Maybe you should replace vmwareGetVMStatus with vmwareUpdateVMStatus
 that updates the cached information in a virDomainObj and call it in
 all places that read information from a virDomainObj.
 
 A more general question: is this driver supposed to work properly when
 someone uses vmrun to alter a VMs behind libvirt's back? If that's the
 case then maybe this driver should not cache anything at all and work
 like the vSphere, Hyper-V or VirtualBox driver. They always query the
 hypervisor for information and cache nothing.
 
 I'm not sure what's the best approach here.

Hi,

The problem here is that contrary to vSphere, Hyper-V or VirtualBox, I have no 
way to get a list of defined domains as vmrun only lists running domains.
So I think I'll do as you suggested and go for a vmwareUpdateVMStatus
function.

Regards,
Jean-Baptiste

-- 
Jean-Baptiste ROUAULT
Ingénieur RD - diateam : Architectes de l'information
Phone : +33 (0)9 53 16 02 70 Fax : +33 (0)2 98 050 051

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

[libvirt] [Patch v2] vmx: Better Workstation vmx handling

2012-02-23 Thread Jean-Baptiste Rouault
This patch adds support for more network configurations in vmx files.

Changes since v1:
Adapt virVMXFormatEthernet() to handle empty bridge names and user
interface type.
Add new test cases to vmx2xmltest and xml2vmxtest.

Jean-Baptiste Rouault (1):
  vmx: Better Workstation vmx handling

 src/vmx/vmx.c  |   39 --
 tests/vmx2xmldata/vmx2xml-ethernet-nat.vmx |6 +++
 tests/vmx2xmldata/vmx2xml-ethernet-nat.xml |   21 ++
 tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.vmx |   52 
 tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.xml |   35 
 tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.vmx |   52 
 tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml |   36 
 tests/vmx2xmltest.c|4 ++
 tests/xml2vmxdata/xml2vmx-ethernet-nat.vmx |   14 ++
 tests/xml2vmxdata/xml2vmx-ethernet-nat.xml |   13 ++
 tests/xml2vmxdata/xml2vmx-ws-in-the-wild-1.vmx |   22 ++
 tests/xml2vmxdata/xml2vmx-ws-in-the-wild-1.xml |   29 +
 tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.vmx |   22 ++
 tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.xml |   30 ++
 tests/xml2vmxtest.c|4 ++
 15 files changed, 366 insertions(+), 13 deletions(-)
 create mode 100644 tests/vmx2xmldata/vmx2xml-ethernet-nat.vmx
 create mode 100644 tests/vmx2xmldata/vmx2xml-ethernet-nat.xml
 create mode 100644 tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.vmx
 create mode 100644 tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.xml
 create mode 100644 tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.vmx
 create mode 100644 tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml
 create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-nat.vmx
 create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-nat.xml
 create mode 100644 tests/xml2vmxdata/xml2vmx-ws-in-the-wild-1.vmx
 create mode 100644 tests/xml2vmxdata/xml2vmx-ws-in-the-wild-1.xml
 create mode 100644 tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.vmx
 create mode 100644 tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.xml

-- 
1.7.9

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


[libvirt] [Patch v2] vmx: Better Workstation vmx handling

2012-02-23 Thread Jean-Baptiste Rouault
This patch adds support for vmx files with empty networkName
values (which is the case for vmx generated by Workstation).
It also adds support for vmx containing NATed network interfaces.

Update test suite accordingly
---
 src/vmx/vmx.c  |   39 --
 tests/vmx2xmldata/vmx2xml-ethernet-nat.vmx |6 +++
 tests/vmx2xmldata/vmx2xml-ethernet-nat.xml |   21 ++
 tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.vmx |   52 
 tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.xml |   35 
 tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.vmx |   52 
 tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml |   36 
 tests/vmx2xmltest.c|4 ++
 tests/xml2vmxdata/xml2vmx-ethernet-nat.vmx |   14 ++
 tests/xml2vmxdata/xml2vmx-ethernet-nat.xml |   13 ++
 tests/xml2vmxdata/xml2vmx-ws-in-the-wild-1.vmx |   22 ++
 tests/xml2vmxdata/xml2vmx-ws-in-the-wild-1.xml |   29 +
 tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.vmx |   22 ++
 tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.xml |   30 ++
 tests/xml2vmxtest.c|4 ++
 15 files changed, 366 insertions(+), 13 deletions(-)
 create mode 100644 tests/vmx2xmldata/vmx2xml-ethernet-nat.vmx
 create mode 100644 tests/vmx2xmldata/vmx2xml-ethernet-nat.xml
 create mode 100644 tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.vmx
 create mode 100644 tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.xml
 create mode 100644 tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.vmx
 create mode 100644 tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml
 create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-nat.vmx
 create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-nat.xml
 create mode 100644 tests/xml2vmxdata/xml2vmx-ws-in-the-wild-1.vmx
 create mode 100644 tests/xml2vmxdata/xml2vmx-ws-in-the-wild-1.xml
 create mode 100644 tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.vmx
 create mode 100644 tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.xml

diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 823d5df..910bb0e 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -2418,12 +2418,20 @@ virVMXParseEthernet(virConfPtr conf, int controller, 
virDomainNetDefPtr *def)
 }
 
 /* vmx:networkName - def:data.bridge.brname */
-if ((connectionType == NULL ||
- STRCASEEQ(connectionType, bridged) ||
- STRCASEEQ(connectionType, custom)) 
-virVMXGetConfigString(conf, networkName_name, networkName,
-  false)  0) {
-goto cleanup;
+if (connectionType == NULL ||
+STRCASEEQ(connectionType, bridged) ||
+STRCASEEQ(connectionType, custom)) {
+if (virVMXGetConfigString(conf, networkName_name, networkName,
+  true)  0)
+goto cleanup;
+
+if (networkName == NULL) {
+networkName = strdup();
+if (networkName == NULL) {
+virReportOOMError();
+goto cleanup;
+}
+}
 }
 
 /* vmx:vnet - def:data.ifname */
@@ -2447,11 +2455,10 @@ virVMXParseEthernet(virConfPtr conf, int controller, 
virDomainNetDefPtr *def)
   connectionType, connectionType_name);
 goto cleanup;
 } else if (STRCASEEQ(connectionType, nat)) {
-/* FIXME */
-VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
-  _(No yet handled value '%s' for VMX entry '%s'),
-  connectionType, connectionType_name);
-goto cleanup;
+(*def)-type = VIR_DOMAIN_NET_TYPE_USER;
+(*def)-model = virtualDev;
+
+virtualDev = NULL;
 } else if (STRCASEEQ(connectionType, custom)) {
 (*def)-type = VIR_DOMAIN_NET_TYPE_BRIDGE;
 (*def)-model = virtualDev;
@@ -3533,8 +3540,9 @@ virVMXFormatEthernet(virDomainNetDefPtr def, int 
controller,
 /* def:type, def:ifname - vmx:connectionType */
 switch (def-type) {
   case VIR_DOMAIN_NET_TYPE_BRIDGE:
-virBufferAsprintf(buffer, ethernet%d.networkName = \%s\\n,
-  controller, def-data.bridge.brname);
+if (STRNEQ(def-data.bridge.brname, ))
+virBufferAsprintf(buffer, ethernet%d.networkName = \%s\\n,
+  controller, def-data.bridge.brname);
 
 if (def-ifname != NULL) {
 virBufferAsprintf(buffer, ethernet%d.connectionType = 
\custom\\n,
@@ -3548,6 +3556,11 @@ virVMXFormatEthernet(virDomainNetDefPtr def, int 
controller,
 
 break;
 
+  case VIR_DOMAIN_NET_TYPE_USER:
+virBufferAsprintf(buffer, ethernet%d.connectionType = \nat\\n,
+  controller);
+break;
+
   default:
 VMX_ERROR(VIR_ERR_CONFIG_UNSUPPORTED, _(Unsupported net type '%s'),
   virDomainNetTypeToString(def-type));
diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-nat.vmx 

[libvirt] [PATCH 1/2] vmware: implement domainXMLFromNative

2012-02-22 Thread Jean-Baptiste Rouault
---
 src/vmware/vmware_driver.c |   31 +++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index 56e9d2d..8f9d922 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -844,6 +844,36 @@ vmwareDomainGetXMLDesc(virDomainPtr dom, unsigned int 
flags)
 return ret;
 }
 
+static char *
+vmwareDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat,
+  const char *nativeConfig,
+  unsigned int flags)
+{
+struct vmware_driver *driver = conn-privateData;
+virVMXContext ctx;
+virDomainDefPtr def = NULL;
+char *xml = NULL;
+
+virCheckFlags(0, NULL);
+
+if (STRNEQ(nativeFormat, vmware-vmx)) {
+vmwareError(VIR_ERR_INVALID_ARG,
+_(Unsupported config format '%s'), nativeFormat);
+return NULL;
+}
+
+ctx.parseFileName = vmwareCopyVMXFileName;
+
+def = virVMXParseConfig(ctx, driver-caps, nativeConfig);
+
+if (def != NULL)
+xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE);
+
+virDomainDefFree(def);
+
+return xml;
+}
+
 static int
 vmwareNumDefinedDomains(virConnectPtr conn)
 {
@@ -988,6 +1018,7 @@ static virDriver vmwareDriver = {
 .domainGetInfo = vmwareDomainGetInfo, /* 0.8.7 */
 .domainGetState = vmwareDomainGetState, /* 0.9.2 */
 .domainGetXMLDesc = vmwareDomainGetXMLDesc, /* 0.8.7 */
+.domainXMLFromNative = vmwareDomainXMLFromNative, /* 0.9.11 */
 .listDefinedDomains = vmwareListDefinedDomains, /* 0.8.7 */
 .numOfDefinedDomains = vmwareNumDefinedDomains, /* 0.8.7 */
 .domainCreate = vmwareDomainCreate, /* 0.8.7 */
-- 
1.7.9

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


[libvirt] [PATCH 0/2] VMware Workstation domainXMLFromNative support

2012-02-22 Thread Jean-Baptiste Rouault
These patches add domainXMLFromNative to the vmware driver
and add support for more network configurations in vmx files

Jean-Baptiste Rouault (2):
  vmware: implement domainXMLFromNative
  vmx: Better Workstation vmx handling

 src/vmware/vmware_driver.c |   31 +++
 src/vmx/vmx.c  |   29 ++---
 2 files changed, 49 insertions(+), 11 deletions(-)

-- 
1.7.9

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


[libvirt] [PATCH 2/2] vmx: Better Workstation vmx handling

2012-02-22 Thread Jean-Baptiste Rouault
This patch adds support for vmx files with empty networkName
values (which is the case for vmx generated by Workstation).

It also adds support for vmx containing NATed network interfaces.
---
 src/vmx/vmx.c |   29 ++---
 1 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 823d5df..3cc3b10 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -2418,12 +2418,20 @@ virVMXParseEthernet(virConfPtr conf, int controller, 
virDomainNetDefPtr *def)
 }
 
 /* vmx:networkName - def:data.bridge.brname */
-if ((connectionType == NULL ||
- STRCASEEQ(connectionType, bridged) ||
- STRCASEEQ(connectionType, custom)) 
-virVMXGetConfigString(conf, networkName_name, networkName,
-  false)  0) {
-goto cleanup;
+if (connectionType == NULL ||
+STRCASEEQ(connectionType, bridged) ||
+STRCASEEQ(connectionType, custom)) {
+if (virVMXGetConfigString(conf, networkName_name, networkName,
+  true)  0)
+goto cleanup;
+
+if (networkName == NULL) {
+networkName = strdup();
+if (networkName == NULL) {
+virReportOOMError();
+goto cleanup;
+}
+}
 }
 
 /* vmx:vnet - def:data.ifname */
@@ -2447,11 +2455,10 @@ virVMXParseEthernet(virConfPtr conf, int controller, 
virDomainNetDefPtr *def)
   connectionType, connectionType_name);
 goto cleanup;
 } else if (STRCASEEQ(connectionType, nat)) {
-/* FIXME */
-VMX_ERROR(VIR_ERR_INTERNAL_ERROR,
-  _(No yet handled value '%s' for VMX entry '%s'),
-  connectionType, connectionType_name);
-goto cleanup;
+(*def)-type = VIR_DOMAIN_NET_TYPE_USER;
+(*def)-model = virtualDev;
+
+virtualDev = NULL;
 } else if (STRCASEEQ(connectionType, custom)) {
 (*def)-type = VIR_DOMAIN_NET_TYPE_BRIDGE;
 (*def)-model = virtualDev;
-- 
1.7.9

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


[libvirt] [PATCH] vmware: detect when a domain was shut down from the inside

2012-02-01 Thread Jean-Baptiste Rouault
This patch adds an internal function vmwareGetVMStatus to
get the real state of the domain. This function is used in
various places in the driver, in particular to detect when
the domain has been shut down by the user with the halt
command.
---
 src/vmware/vmware_driver.c |   83 +---
 1 files changed, 70 insertions(+), 13 deletions(-)

diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index 56e9d2d..6f75f86 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -28,6 +28,7 @@
 #include datatypes.h
 #include virfile.h
 #include memory.h
+#include util.h
 #include uuid.h
 #include command.h
 #include vmx.h
@@ -181,6 +182,50 @@ vmwareGetVersion(virConnectPtr conn, unsigned long 
*version)
 }
 
 static int
+vmwareGetVMStatus(struct vmware_driver *driver,
+  virDomainObjPtr vm,
+  int *status,
+  int *reason)
+{
+virCommandPtr cmd;
+char *outbuf;
+char *vmxAbsolutePath;
+int state;
+int ret = -1;
+
+cmd = virCommandNewArgList(VMRUN, -T, vmw_types[driver-type],
+   list, NULL);
+virCommandSetOutputBuffer(cmd, outbuf);
+if (virCommandRun(cmd, NULL)  0)
+goto cleanup;
+
+state = virDomainObjGetState(vm, reason);
+
+if (virFileResolveAllLinks(((vmwareDomainPtr) vm-privateData)-vmxPath,
+   vmxAbsolutePath) == -1)
+goto cleanup;
+
+if (strstr(outbuf, vmxAbsolutePath)) {
+/* If the vmx path is in the output, the domain is running or
+ * is paused but we have no way to detect if it is paused or not. */
+if (state == VIR_DOMAIN_PAUSED)
+*status = state;
+else
+*status = VIR_DOMAIN_RUNNING;
+} else {
+*status = VIR_DOMAIN_SHUTOFF;
+}
+
+ret = 0;
+
+cleanup:
+virCommandFree(cmd);
+VIR_FREE(outbuf);
+VIR_FREE(vmxAbsolutePath);
+return ret;
+}
+
+static int
 vmwareStopVM(struct vmware_driver *driver,
  virDomainObjPtr vm,
  virDomainShutoffReason reason)
@@ -212,12 +257,6 @@ vmwareStartVM(struct vmware_driver *driver, 
virDomainObjPtr vm)
 };
 const char *vmxPath = ((vmwareDomainPtr) vm-privateData)-vmxPath;
 
-if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_SHUTOFF) {
-vmwareError(VIR_ERR_OPERATION_INVALID, %s,
-_(domain is not in shutoff state));
-return -1;
-}
-
 vmwareSetSentinal(cmd, vmw_types[driver-type]);
 vmwareSetSentinal(cmd, vmxPath);
 if (!((vmwareDomainPtr) vm-privateData)-gui)
@@ -317,6 +356,7 @@ vmwareDomainShutdownFlags(virDomainPtr dom,
 {
 struct vmware_driver *driver = dom-conn-privateData;
 virDomainObjPtr vm;
+int status;
 int ret = -1;
 
 virCheckFlags(0, -1);
@@ -331,7 +371,10 @@ vmwareDomainShutdownFlags(virDomainPtr dom,
 goto cleanup;
 }
 
-if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_RUNNING) {
+if (vmwareGetVMStatus(driver, vm, status, NULL) == -1)
+goto cleanup;
+
+if (status != VIR_DOMAIN_RUNNING) {
 vmwareError(VIR_ERR_INTERNAL_ERROR, %s,
 _(domain is not in running state));
 goto cleanup;
@@ -467,6 +510,7 @@ vmwareDomainReboot(virDomainPtr dom, unsigned int flags)
 VMRUN, -T, PROGRAM_SENTINAL,
 reset, PROGRAM_SENTINAL, soft, NULL
 };
+int status;
 int ret = -1;
 
 virCheckFlags(0, -1);
@@ -485,8 +529,10 @@ vmwareDomainReboot(virDomainPtr dom, unsigned int flags)
 vmwareSetSentinal(cmd, vmw_types[driver-type]);
 vmwareSetSentinal(cmd, vmxPath);
 
+if (vmwareGetVMStatus(driver, vm, status, NULL) == -1)
+goto cleanup;
 
-if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_RUNNING) {
+if (status != VIR_DOMAIN_RUNNING) {
 vmwareError(VIR_ERR_INTERNAL_ERROR, %s,
 _(domain is not in running state));
 goto cleanup;
@@ -582,6 +628,7 @@ vmwareDomainCreateWithFlags(virDomainPtr dom,
 {
 struct vmware_driver *driver = dom-conn-privateData;
 virDomainObjPtr vm;
+int status;
 int ret = -1;
 
 virCheckFlags(0, -1);
@@ -596,7 +643,10 @@ vmwareDomainCreateWithFlags(virDomainPtr dom,
 goto cleanup;
 }
 
-if (virDomainObjIsActive(vm)) {
+if (vmwareGetVMStatus(driver, vm, status, NULL) == -1)
+goto cleanup;
+
+if (status != VIR_DOMAIN_SHUTOFF) {
 vmwareError(VIR_ERR_OPERATION_INVALID,
 %s, _(Domain is already running));
 goto cleanup;
@@ -623,6 +673,7 @@ vmwareDomainUndefineFlags(virDomainPtr dom,
 {
 struct vmware_driver *driver = dom-conn-privateData;
 virDomainObjPtr vm;
+int status;
 int ret = -1;
 
 virCheckFlags(0, -1);
@@ -645,7 +696,10 @@ vmwareDomainUndefineFlags(virDomainPtr dom,
 goto cleanup;
 }
 
-if (virDomainObjIsActive(vm)) {
+if (vmwareGetVMStatus(driver, vm, status, 

[libvirt] [PATCH] openvz: detect when a domain was shut down from the inside

2011-07-29 Thread Jean-Baptiste Rouault
This patch adds an internal function openvzGetVEStatus to
get the real state of the domain. This function is used in
various places in the driver, in particular to detect when
the domain has been shut down by the user with the halt
command.
---
 src/openvz/openvz_driver.c |   76 +++-
 1 files changed, 68 insertions(+), 8 deletions(-)

diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 4e7cb03..3b3b079 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -72,6 +72,7 @@ static int openvzDomainSetVcpusInternal(virDomainObjPtr vm,
 unsigned int nvcpus);
 static int openvzDomainSetMemoryInternal(virDomainObjPtr vm,
  unsigned long memory);
+static int openvzGetVEStatus(virDomainObjPtr vm, int *status, int *reason);
 
 static void openvzDriverLock(struct openvz_driver *driver)
 {
@@ -340,6 +341,7 @@ static int openvzDomainGetInfo(virDomainPtr dom,
virDomainInfoPtr info) {
 struct openvz_driver *driver = dom-conn-privateData;
 virDomainObjPtr vm;
+int state;
 int ret = -1;
 
 openvzDriverLock(driver);
@@ -352,9 +354,11 @@ static int openvzDomainGetInfo(virDomainPtr dom,
 goto cleanup;
 }
 
-info-state = virDomainObjGetState(vm, NULL);
+if (openvzGetVEStatus(vm, state, NULL) == -1)
+goto cleanup;
+info-state = state;
 
-if (!virDomainObjIsActive(vm)) {
+if (info-state != VIR_DOMAIN_RUNNING) {
 info-cpuTime = 0;
 } else {
 if (openvzGetProcessInfo((info-cpuTime), dom-id)  0) {
@@ -398,8 +402,7 @@ openvzDomainGetState(virDomainPtr dom,
 goto cleanup;
 }
 
-*state = virDomainObjGetState(vm, reason);
-ret = 0;
+ret = openvzGetVEStatus(vm, state, reason);
 
 cleanup:
 if (vm)
@@ -584,6 +587,7 @@ openvzDomainShutdownFlags(virDomainPtr dom,
 virDomainObjPtr vm;
 const char *prog[] = {VZCTL, --quiet, stop, PROGRAM_SENTINAL, NULL};
 int ret = -1;
+int status;
 
 virCheckFlags(0, -1);
 
@@ -596,9 +600,12 @@ openvzDomainShutdownFlags(virDomainPtr dom,
 _(no domain with matching uuid));
 goto cleanup;
 }
+
+if (openvzGetVEStatus(vm, status, NULL) == -1)
+goto cleanup;
 
 openvzSetProgramSentinal(prog, vm-def-name);
-if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_RUNNING) {
+if (status != VIR_DOMAIN_RUNNING) {
 openvzError(VIR_ERR_INTERNAL_ERROR, %s,
 _(domain is not in running state));
 goto cleanup;
@@ -631,6 +638,7 @@ static int openvzDomainReboot(virDomainPtr dom,
 virDomainObjPtr vm;
 const char *prog[] = {VZCTL, --quiet, restart, PROGRAM_SENTINAL, NULL};
 int ret = -1;
+int status;
 
 virCheckFlags(0, -1);
 
@@ -644,8 +652,11 @@ static int openvzDomainReboot(virDomainPtr dom,
 goto cleanup;
 }
 
+if (openvzGetVEStatus(vm, status, NULL) == -1)
+goto cleanup;
+
 openvzSetProgramSentinal(prog, vm-def-name);
-if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_RUNNING) {
+if (status != VIR_DOMAIN_RUNNING) {
 openvzError(VIR_ERR_INTERNAL_ERROR, %s,
 _(domain is not in running state));
 goto cleanup;
@@ -1052,6 +1063,7 @@ openvzDomainCreateWithFlags(virDomainPtr dom, unsigned 
int flags)
 virDomainObjPtr vm;
 const char *prog[] = {VZCTL, --quiet, start, PROGRAM_SENTINAL, NULL };
 int ret = -1;
+int status;
 
 virCheckFlags(0, -1);
 
@@ -1064,8 +1076,11 @@ openvzDomainCreateWithFlags(virDomainPtr dom, unsigned 
int flags)
 _(no domain with matching id));
 goto cleanup;
 }
+
+if (openvzGetVEStatus(vm, status, NULL) == -1)
+goto cleanup;
 
-if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_SHUTOFF) {
+if (status != VIR_DOMAIN_SHUTOFF) {
 openvzError(VIR_ERR_OPERATION_DENIED, %s,
 _(domain is not in shutoff state));
 goto cleanup;
@@ -1102,6 +1117,7 @@ openvzDomainUndefineFlags(virDomainPtr dom,
 virDomainObjPtr vm;
 const char *prog[] = { VZCTL, --quiet, destroy, PROGRAM_SENTINAL, NULL 
};
 int ret = -1;
+int status;
 
 virCheckFlags(0, -1);
 
@@ -1113,7 +1129,10 @@ openvzDomainUndefineFlags(virDomainPtr dom,
 goto cleanup;
 }
 
-if (virDomainObjIsActive(vm)) {
+if (openvzGetVEStatus(vm, status, NULL) == -1)
+goto cleanup;
+
+if (status != VIR_DOMAIN_SHUTOFF) {
 openvzError(VIR_ERR_OPERATION_INVALID, %s,
 _(cannot delete active domain));
 goto cleanup;
@@ -1610,6 +1629,47 @@ cleanup:
 return -1;
 }
 
+static int
+openvzGetVEStatus(virDomainObjPtr vm, int *status, int *reason)
+{
+virCommandPtr cmd;
+char *outbuf;
+char *line;
+int state;
+int ret = -1;
+
+cmd = virCommandNewArgList(VZLIST, vm-def-name, 

[libvirt] [PATCH] Fix compilation error when SASL support is disabled

2011-07-05 Thread Jean-Baptiste Rouault
This patch adds #if HAVE_SASL where needed in libvirtd.h
---
 daemon/libvirtd.h |8 +++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/daemon/libvirtd.h b/daemon/libvirtd.h
index 6c604fc..8e1843c 100644
--- a/daemon/libvirtd.h
+++ b/daemon/libvirtd.h
@@ -38,7 +38,9 @@
 # include logging.h
 # include threads.h
 # include network.h
-# include virnetsaslcontext.h
+# if HAVE_SASL
+#  include virnetsaslcontext.h
+# endif
 # include virnetserverprogram.h
 
 # if WITH_DTRACE
@@ -70,7 +72,9 @@ struct daemonClientPrivate {
 
 int domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LAST];
 
+# if HAVE_SASL
 virNetSASLSessionPtr sasl;
+# endif
 
 /* This is only valid if a remote open call has been made on this
  * connection, otherwise it will be NULL.  Also if remote close is
@@ -81,7 +85,9 @@ struct daemonClientPrivate {
 daemonClientStreamPtr streams;
 };
 
+# if HAVE_SASL
 extern virNetSASLContextPtr saslCtxt;
+# endif
 extern virNetServerProgramPtr remoteProgram;
 extern virNetServerProgramPtr qemuProgram;
 
-- 
1.7.5.4

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


Re: [libvirt] [PATCH] Fix compilation error when SASL support is disabled

2011-07-05 Thread Jean-Baptiste Rouault
On Tuesday 05 July 2011 17:43:06 Daniel P. Berrange wrote:
 On Tue, Jul 05, 2011 at 05:30:09PM +0200, Jean-Baptiste Rouault wrote:
  This patch adds #if HAVE_SASL where needed in libvirtd.h
  ---
  
   daemon/libvirtd.h |8 +++-
   1 files changed, 7 insertions(+), 1 deletions(-)
 
 This was already fixed last week
 
 commit 0e4b921a57b670bbe55c27d17ca19aa5780ee196
 Author: Daniel P. Berrange berra...@redhat.com
 Date:   Thu Jun 30 18:18:08 2011 +0100
 
 Add conditionals to allow build without SASL
 
 * daemon/libvirtd.c, daemon/remote.c: Add #if HAVE_SASL and
   suitable function stubs to allow build without SASL
 
 
 Daniel

Hi,

The patch you are referring to adds conditionals to libvirtd.c and remote.c.
My patch adds conditionals to the libvirtd.h file because it includes
virnetsaslcontext.h and uses SASL-related types and libvirt fails to build
with --without-sasl flag.

Regards,
Jean-Baptiste

-- 
Jean-Baptiste ROUAULT
Ingénieur RD - Diateam : Architectes de l'information
Phone : +33 (0)9 53 16 02 70 Fax : +33 (0)2 98 050 051

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

[libvirt] [PATCH] openvz: fix bridge devices parsing in openvzReadNetworkConf()

2011-05-31 Thread Jean-Baptiste Rouault
strchrnul() was called on the wrong string so it returned
the same result for each iteration.
---
 src/openvz/openvz_conf.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
index 5f33f75..6e32242 100644
--- a/src/openvz/openvz_conf.c
+++ b/src/openvz/openvz_conf.c
@@ -237,7 +237,7 @@ openvzReadNetworkConf(virDomainDefPtr def,
 
 /*parse string*/
 do {
-char *next = strchrnul (token, ',');
+char *next = strchrnul (p, ',');
 if (STRPREFIX(p, ifname=)) {
 /* skip in libvirt */
 } else if (STRPREFIX(p, host_ifname=)) {
-- 
1.7.1

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


Re: [libvirt] [PATCH] openvz: fix bridge devices parsing in openvzReadNetworkConf()

2011-05-31 Thread Jean-Baptiste Rouault
On Tuesday 31 May 2011 14:41:55 Matthias Bolte wrote:
 I also added a testcase and looked at the other config parsing code in
 the OpenVZ driver. I thing that openvzLoadDomains is missing this
 line:
 
   dom-def-virtType = VIR_DOMAIN_VIRT_OPENVZ;
 
 Could you do a virsh dumpxml for an OpenVZ guest and check the first
 line of XML? I think it currently reads
 
   domain type='qemu'
 
 but should actually read
 
   domain type='openvz'
 
 and we need to fix this.
 
 Matthias

It indeed outputs domain type='qemu'

Regards,
Jean-Baptiste

-- 
Jean-Baptiste ROUAULT
Ingénieur RD - Diateam : Architectes de l'information
Phone : +33 (0)9 53 16 02 70 Fax : +33 (0)2 98 050 051

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

[libvirt] [PATCH] OpenVZ driver: fix openvzGetVPSUUID()

2011-05-27 Thread Jean-Baptiste Rouault
openvzGetUUID did not work since openvz_readline()
was replaced by getline()
---
 src/openvz/openvz_conf.c |   13 ++---
 1 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
index 2cccd81..7b939b2 100644
--- a/src/openvz/openvz_conf.c
+++ b/src/openvz/openvz_conf.c
@@ -863,7 +863,6 @@ openvzGetVPSUUID(int vpsid, char *uuidstr, size_t len)
 char *conf_file;
 char *line = NULL;
 size_t line_size = 0;
-ssize_t ret;
 char *saveptr = NULL;
 char *uuidbuf;
 char *iden;
@@ -877,16 +876,8 @@ openvzGetVPSUUID(int vpsid, char *uuidstr, size_t len)
 if (fp == NULL)
 goto cleanup;
 
-while (1) {
-ret = getline(line, line_size, fp);
-if (ret == -1)
-goto cleanup;
-
-if (ret == 0) { /* EoF, UUID was not found */
-uuidstr[0] = 0;
-break;
-}
-
+uuidstr[0] = 0;
+while (getline(line, line_size, fp) = 0) {
 iden = strtok_r(line,  , saveptr);
 uuidbuf = strtok_r(NULL, \n, saveptr);
 
-- 
1.7.1

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


Re: [libvirt] [PATCH] OpenVZ driver: fix openvzGetVPSUUID()

2011-05-27 Thread Jean-Baptiste Rouault
On Friday 27 May 2011 13:51:05 Matthias Bolte wrote:

 We need distinguish between getline returning -1 because of EOF and
 because of another error. I missed this problem in the other
 regression fix and posted a follow up patch [1] for this.
 
 I propose the attached patch as v2 for you patch. I assume you have an
 OpenVZ setup at hand, could you test this patch?
 
 [1] https://www.redhat.com/archives/libvir-list/2011-May/msg01788.html
 
 Matthias

I tested your patch and it seems to work fine.

Regards,
Jean-Baptiste

-- 
Jean-Baptiste ROUAULT
Ingénieur RD - Diateam : Architectes de l'information
Phone : +33 (0)9 53 16 02 70 Fax : +33 (0)2 98 050 051

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


Re: [libvirt] [PATCH] OpenVZ driver: fix openvzGetVPSUUID()

2011-05-27 Thread Jean-Baptiste Rouault
On Friday 27 May 2011 16:01:32 Matthias Bolte wrote:
 Thanks, pushed then.
 
 There are other usages of getline in the OpenVZ driver, but they
 should all be safe because they don't distinguish between 0 and -1,
 except openvzGetProcessInfo.
 
 Jean-Baptiste could you test virsh dominfo of a running OpenVZ domain?
 I expect it to currently fail and will post a patch for it.
 
 Matthias

virsh dominfo on a running domain doesn't fail here :
 virsh # dominfo 100
 ID :   100
 Nom :  100
 UUID : 0a0cf7cb-efb4-4065-ac2d-e63ad51e72cf
 Type de SE :   exe
 État :en cours d'exécution
 CPU :  1
 Temps CPU :2,3s
 Mémoire Max : 262144 kB
 Mémoire utilisée : 262144 kB
 Persistent: yes
 Autostart:  disable

I tried it on a stopped domain and it doesn't fail either.

Jean-Baptiste

-- 
Jean-Baptiste ROUAULT
Ingénieur RD - Diateam : Architectes de l'information
Phone : +33 (0)9 53 16 02 70 Fax : +33 (0)2 98 050 051

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

[libvirt] [PATCH] docs: remove returns word from beginning of lines

2011-04-07 Thread Jean-Baptiste Rouault
Move returns keyword from beginning of API doc lines
when it does not describe return values.
Maybe the API doc extractor could be changed to look for
returns:  to avoid such confusion.
---
 src/libvirt.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index 85dfc58..344e921 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -10097,8 +10097,8 @@ error:
  *
  * The virDomainPtr object handle passed into the callback upon delivery
  * of an event is only valid for the duration of execution of the callback.
- * If the callback wishes to keep the domain object after the callback
- * returns, it shall take a reference to it, by calling virDomainRef.
+ * If the callback wishes to keep the domain object after the callback returns,
+ * it shall take a reference to it, by calling virDomainRef.
  * The reference can be released once the object is no longer required
  * by calling virDomainFree.
  *
@@ -12727,8 +12727,8 @@ error:
  *
  * The virDomainPtr object handle passed into the callback upon delivery
  * of an event is only valid for the duration of execution of the callback.
- * If the callback wishes to keep the domain object after the callback
- * returns, it shall take a reference to it, by calling virDomainRef.
+ * If the callback wishes to keep the domain object after the callback returns,
+ * it shall take a reference to it, by calling virDomainRef.
  * The reference can be released once the object is no longer required
  * by calling virDomainFree.
  *
-- 
1.7.0.4

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


Re: [libvirt] [RFC] Add flag for virsh undefine to remove/wipe the disk devices

2011-03-31 Thread Jean-Baptiste Rouault
On Thursday 31 March 2011 10:04:36 Osier Yang wrote:
 于 2011年03月30日 23:56, Jean-Baptiste Rouault 写道:
  On Wednesday 30 March 2011 17:23:51 Osier Yang wrote:
  Yes, actually I also prefer to add new flag to API, but not in
  virsh instead, however, adding new flag argument is not workable,
  how about introduce a new API, something like virDomainUndefineFlag?
  
  I wanted to suggest something similar because I'm annoyed that
  calling undefine on an OpenVZ domain destroys the container private
  area...
 
 Hi, Jean
 
 Could you explain more? Wanna known if can do it incidentally, though
 I'm guessing it's caused by openvz driver destroying the private
 area internally, something like vzctl --destroy. If it's right
 for your meaning, then IMHO we can't introduce new flag for this,
 as it's only openvz driver specificly.
 
 Regards
 Osier

Hi,

Yes the problem is OpenVZ specific because vzctl destroy internally destroys 
the private area.
If there is a new virDomainUndefineFlag API, I was thinking that maybe the
openvz driver could check the value of that flag in openvzDomainUndefine(),
then only remove the container config file in one case, or use vzctl destroy
in the other case.
To make it cleaner, a patch could be send upstream so that vzctl destroy 
accepts a new argument like --keep-private.

Regards
Jean-Baptiste

-- 
Jean-Baptiste ROUAULT
Ingénieur RD - Diateam : Architectes de l'information
Phone : +33 (0)9 53 16 02 70 Fax : +33 (0)2 98 050 051

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

Re: [libvirt] [RFC] Add flag for virsh undefine to remove/wipe the disk devices

2011-03-30 Thread Jean-Baptiste Rouault
On Wednesday 30 March 2011 17:23:51 Osier Yang wrote:
 Yes, actually I also prefer to add new flag to API, but not in
 virsh instead, however, adding new flag argument is not workable,
 how about introduce a new API, something like virDomainUndefineFlag?

I wanted to suggest something similar because I'm annoyed that
calling undefine on an OpenVZ domain destroys the container private area...

-- 
Jean-Baptiste ROUAULT
Ingénieur RD - Diateam : Architectes de l'information
Phone : +33 (0)9 53 16 02 70 Fax : +33 (0)2 98 050 051

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

[libvirt] [PATCH] openvz: fix a simple bug in openvzListDefinedDomains()

2011-03-18 Thread Jean-Baptiste Rouault
This patch adds missing curly brackets to an if
statement in openvzListDefinedDomains()
---
 src/openvz/openvz_driver.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 0d64e19..7792136 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -1444,9 +1444,10 @@ static int openvzListDefinedDomains(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 continue;
 }
 snprintf(vpsname, sizeof(vpsname), %d, veid);
-if (!(names[got] = strdup(vpsname)))
+if (!(names[got] = strdup(vpsname))) {
 virReportOOMError();
 goto out;
+}
 got ++;
 }
 waitpid(pid, NULL, 0);
-- 
1.7.0.4

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


[libvirt] [PATCH] Add info about VMware driver to the libvirt website

2010-12-23 Thread Jean-Baptiste Rouault
---
 docs/drivers.html.in   |1 +
 docs/drvvmware.html.in |   67 
 docs/index.html.in |3 ++
 3 files changed, 71 insertions(+), 0 deletions(-)
 create mode 100644 docs/drvvmware.html.in

diff --git a/docs/drivers.html.in b/docs/drivers.html.in
index b97200c..ecad03a 100644
--- a/docs/drivers.html.in
+++ b/docs/drivers.html.in
@@ -27,6 +27,7 @@
   listronga href=drvuml.htmlUML/a/strong - User Mode Linux/li
   listronga href=drvvbox.htmlVirtualBox/a/strong/li
   listronga href=drvesx.htmlVMware ESX/a/strong/li
+  listronga href=drvvmware.htmlVMware 
Workstation/Player/a/strong/li
   listronga href=drvxen.htmlXen/a/strong/li
 /ul
 
diff --git a/docs/drvvmware.html.in b/docs/drvvmware.html.in
new file mode 100644
index 000..273e0a0
--- /dev/null
+++ b/docs/drvvmware.html.in
@@ -0,0 +1,67 @@
+html
+body
+h1VMware Workstation/Player hypervisors driver/h1
+p
+The libvirt VMware Workstation driver should be able to manage any 
Workstation and
+Player version supported by the VMware VIX API. See the compatibility 
list
+a 
href=http://www.vmware.com/support/developer/vix-api/vix110_reference/;here/a.
+/p
+p
+This driver uses the vmrun utility which is distributed with the VMware 
VIX API.
+You can download the VIX API from a 
href=http://www.vmware.com/support/developer/vix-api/;here/a.
+
+h2Connections to VMware driver/h2
+
+p
+The libvirt VMware driver provides per-user drivers (the session 
instance).
+Two uris are available:
+ul
+  livmwareplayer for VMware Player/li
+  livmwarews for VMware Workstation/li
+/ul
+Some example connection URIs for the driver are:
+/p
+
+pre
+vmwareplayer:///session  (local access to VMware Player 
per-user instance)
+vmwarews:///session  (local access to VMware Workstation 
per-user instance)
+vmwarews+tcp://u...@example.com/session  (remote access to VMware Workstation, 
SASl/Kerberos)
+vmwarews+ssh://u...@example.com/session  (remote access to VMware Workstation, 
SSH tunnelled)
+/pre
+
+h2a name=xmlconfigExample domain XML config/a/h2
+
+pre
+lt;domain type='vmware'gt;
+  lt;namegt;vmwarelt;/namegt;
+  lt;uuidgt;bea92244-8885-4562-828b-3b086731c5b1lt;/uuidgt;
+
+  lt;osgt;
+lt;typegt;hvmlt;/typegt;
+  lt;/osgt;
+
+  lt;memorygt;524288lt;/memorygt;
+  lt;vcpugt;1lt;/vcpugt;
+
+  lt;featuresgt;
+lt;pae/gt;
+lt;acpi/gt;
+  lt;/featuresgt;
+
+  lt;devicesgt;
+lt;disk type='file' device='disk'gt;
+  lt;source file='/home/user/tmp/disk.vmdk'/gt;
+  lt;target bus='ide' dev='hda'/gt;
+lt;/diskgt;
+
+lt;interface type='bridge'gt;
+  lt;target dev='/dev/vmnet1'/gt;
+  lt;source bridge=''/gt;
+  lt;mac address='00:16:3e:5d:c7:9e'/gt;
+lt;/interfacegt;
+  lt;/devicesgt;
+lt;/domaingt;
+/pre
+
+/body
+/html
diff --git a/docs/index.html.in b/docs/index.html.in
index 57ea84e..501f3e3 100644
--- a/docs/index.html.in
+++ b/docs/index.html.in
@@ -59,6 +59,9 @@
 The a href=http://www.vmware.com/;VMware ESX and GSX/a hypervisors
   /li
   li
+The a href=http://www.vmware.com/;VMware Workstation and Player/a 
hypervisors
+  /li
+  li
 Storage on IDE/SCSI/USB disks, FibreChannel, LVM, iSCSI, NFS and 
filesystems
   /li
 /ul
-- 
1.7.0.4

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


[libvirt] [Patch v5] Add VMware Workstation and Player driver

2010-12-17 Thread Jean-Baptiste Rouault
* Changes since v4:
Fix a bug and a memory leak in vmwareParsePath()
Remove domainSave/Restore functions because more work is needed on them

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


[libvirt] [Patch v5] Add VMware Workstation and Player driver

2010-12-17 Thread Jean-Baptiste Rouault
---
 cfg.mk  |1 +
 configure.ac|7 +
 include/libvirt/virterror.h |1 +
 po/POTFILES.in  |2 +
 src/Makefile.am |   24 +-
 src/driver.h|3 +-
 src/libvirt.c   |   13 +
 src/util/virterror.c|3 +
 src/vmware/vmware_conf.c|  500 +
 src/vmware/vmware_conf.h|   83 
 src/vmware/vmware_driver.c  | 1013 +++
 src/vmware/vmware_driver.h  |   25 +
 12 files changed, 1671 insertions(+), 4 deletions(-)
 create mode 100644 src/vmware/vmware_conf.c
 create mode 100644 src/vmware/vmware_conf.h
 create mode 100644 src/vmware/vmware_driver.c
 create mode 100644 src/vmware/vmware_driver.h

diff --git a/cfg.mk b/cfg.mk
index bda8c57..03186b3 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -388,6 +388,7 @@ msg_gen_function += virXMLError
 msg_gen_function += virXenInotifyError
 msg_gen_function += virXenStoreError
 msg_gen_function += virXendError
+msg_gen_function += vmwareError
 msg_gen_function += xenapiSessionErrorHandler
 msg_gen_function += xenUnifiedError
 msg_gen_function += xenXMError
diff --git a/configure.ac b/configure.ac
index 64e76dc..5ec524d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -227,6 +227,8 @@ AC_ARG_WITH([uml],
   AC_HELP_STRING([--with-uml], [add UML support 
@:@default=check@:@]),[],[with_uml=check])
 AC_ARG_WITH([openvz],
   AC_HELP_STRING([--with-openvz], [add OpenVZ support 
@:@default=yes@:@]),[],[with_openvz=yes])
+AC_ARG_WITH([vmware],
+  AC_HELP_STRING([--with-vmware], [add VMware support 
@:@default=yes@:@]),[],[with_vmware=yes])
 AC_ARG_WITH([libssh2],
   AC_HELP_STRING([--with-libssh2=@:@PFX@:@], [libssh2 location 
@:@default=/usr/local/lib@:@]),[],[with_libssh2=yes])
 AC_ARG_WITH([phyp],
@@ -316,6 +318,10 @@ if test $with_openvz = yes; then
 fi
 AM_CONDITIONAL([WITH_OPENVZ], [test $with_openvz = yes])
 
+if test $with_vmware = yes; then
+AC_DEFINE_UNQUOTED([WITH_VMWARE], 1, [whether VMware driver is enabled])
+fi
+AM_CONDITIONAL([WITH_VMWARE], [test $with_vmware = yes])
 
 dnl
 dnl check for XDR
@@ -2277,6 +2283,7 @@ AC_MSG_NOTICE([ Xen: $with_xen])
 AC_MSG_NOTICE([QEMU: $with_qemu])
 AC_MSG_NOTICE([ UML: $with_uml])
 AC_MSG_NOTICE([  OpenVZ: $with_openvz])
+AC_MSG_NOTICE([  VMware: $with_vmware])
 AC_MSG_NOTICE([VBox: $with_vbox])
 AC_MSG_NOTICE([  XenAPI: $with_xenapi])
 AC_MSG_NOTICE([ LXC: $with_lxc])
diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index eaeb477..a1f88f4 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -52,6 +52,7 @@ typedef enum {
 VIR_FROM_TEST, /* Error from test driver */
 VIR_FROM_REMOTE,   /* Error from remote driver */
 VIR_FROM_OPENVZ,/* Error from OpenVZ driver */
+VIR_FROM_VMWARE,/* Error from VMware driver */
 VIR_FROM_XENXM,/* Error at Xen XM layer */
 VIR_FROM_STATS_LINUX,/* Error in the Linux Stats code */
 VIR_FROM_LXC,   /* Error from Linux Container driver */
diff --git a/po/POTFILES.in b/po/POTFILES.in
index e7be0d3..5561ace 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -100,6 +100,8 @@ src/util/xml.c
 src/vbox/vbox_XPCOMCGlue.c
 src/vbox/vbox_driver.c
 src/vbox/vbox_tmpl.c
+src/vmware/vmware_conf.c
+src/vmware/vmware_driver.c
 src/xen/xen_driver.c
 src/xen/xen_hypervisor.c
 src/xen/xen_inotify.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 196d8af..8bab5e2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -219,8 +219,6 @@ check-local: remote_protocol-structs
 TEST_DRIVER_SOURCES =  \
test/test_driver.c test/test_driver.h
 
-
-
 # Now the Hypervisor specific drivers
 XEN_DRIVER_SOURCES =   \
xen/sexpr.c xen/sexpr.h \
@@ -256,6 +254,10 @@ OPENVZ_DRIVER_SOURCES =
\
openvz/openvz_conf.c openvz/openvz_conf.h   \
openvz/openvz_driver.c openvz/openvz_driver.h
 
+VMWARE_DRIVER_SOURCES =\
+   vmware/vmware_driver.c vmware/vmware.h  \
+   vmware/vmware_conf.c vmware/vmware_conf.h
+
 VBOX_DRIVER_SOURCES =  \
 vbox/vbox_XPCOMCGlue.c vbox/vbox_XPCOMCGlue.h  \
 vbox/vbox_driver.c vbox/vbox_driver.h  \
@@ -601,6 +603,21 @@ endif
 libvirt_driver_openvz_la_SOURCES = $(OPENVZ_DRIVER_SOURCES)
 endif
 
+if WITH_VMWARE
+if WITH_DRIVER_MODULES
+mod_LTLIBRARIES += libvirt_driver_vmware.la
+else
+noinst_LTLIBRARIES += libvirt_driver_vmware.la
+libvirt_la_BUILT_LIBADD += libvirt_driver_vmware.la
+endif
+libvirt_driver_vmware_la_CFLAGS = \
+   -...@top_srcdir@/src/conf
+if WITH_DRIVER_MODULES
+libvirt_driver_vmware_la_LDFLAGS = -module -avoid-version
+endif

[libvirt] [Patch v4] Add VMware Workstation and Player driver

2010-12-14 Thread Jean-Baptiste Rouault
* Changes since v3:
Fix x86_64 guests support checking
Use UNIX PID for the VM ID
Use virDomainObjIsDuplicate() where applicable
Remove the (normally) last duplicated errors
Various minor fixes

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


Re: [libvirt] [Patch v3] Add VMware Workstation and Player driver

2010-12-09 Thread Jean-Baptiste Rouault
On Wednesday 08 December 2010 19:29:56 Daniel P. Berrange wrote:
 
 FYI, you can still get CPUs which are 32-bit only and have vmx/svm
 supported.

Indeed, I didn't know there were 32 bits CPUs with virtualization extensions.
Would it be ok to check for the lm CPU flag to be certain that the host CPU
is a 64bit one ?

  +
  +//vmrun list only reports running vms
  +vm-state = VIR_DOMAIN_RUNNING;
  +vm-def-id = driver-nextvmid++;
  +vm-persistent = 1;
 
 The VM ID is intended to be stable for the lifetime of a VM. It
 seems like this could be unstable, depending on the order in
 which vmrun -T returns the list. Is there any way to find a
 more stable ID, even if it means using the VM's UNIX PID ?

I guess I could parse the first line of the VM log (file vmware.log in the vmx 
directory) to get the PID.

  +static const char *
  +vmwareGetType(virConnectPtr conn)
  +{
  +struct vmware_driver *driver = conn-privateData;
  +int type;
  +
  +type = driver-type;
  +return type == TYPE_PLAYER ? vmware player : vmware workstation;
  +}
 
 This should just be returning the same string that's
 in the type field of the virDriverPtr struct that
 was registered.

Do you mean the name field of the _virDriver struct ?

Regards,
Jean-Baptiste

-- 
Jean-Baptiste ROUAULT
Ingénieur RD - Diateam : Architectes de l'information
Phone : +33 (0)9 53 16 02 70 Fax : +33 (0)2 98 050 051

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

Re: [libvirt] [Patch v3] Add VMware Workstation and Player driver

2010-12-09 Thread Jean-Baptiste Rouault
On Thursday 09 December 2010 11:23:38 Daniel P. Berrange wrote:
 On Thu, Dec 09, 2010 at 11:05:50AM +0100, Jean-Baptiste Rouault wrote:
  On Wednesday 08 December 2010 19:29:56 Daniel P. Berrange wrote:
   FYI, you can still get CPUs which are 32-bit only and have vmx/svm
   supported.
  
  Indeed, I didn't know there were 32 bits CPUs with virtualization
  extensions. Would it be ok to check for the lm CPU flag to be certain
  that the host CPU is a 64bit one ?
 
 You really want to check what the OS is running, not what the CPU is,
 because you can put a 32-bit OS on a 64-bit CPU. Since VMware only
 copes with x86 platforms you can use
 
   STREQ(utsname.machine, x86_64) ? 64 : 32

As far as I know, it is possible to run 64-bit guests on a 32-bit host OS if 
there is a 64-bit CPU with vmx/svm so I think we don't care what the OS is in 
that case, don't we ?

+static const char *
+vmwareGetType(virConnectPtr conn)
+{
+struct vmware_driver *driver = conn-privateData;
+int type;
+
+type = driver-type;
+return type == TYPE_PLAYER ? vmware player : vmware
workstation; +}
   
   This should just be returning the same string that's
   in the type field of the virDriverPtr struct that
   was registered.
  
  Do you mean the name field of the _virDriver struct ?
 
 Yes.

Ok, I thought the connectGetType() API was there to give more information
than the name field if relevant because virConnectGetType() returns
driver-name when the type function isn't available.

Jean-Baptiste

-- 
Jean-Baptiste ROUAULT
Ingénieur RD - Diateam : Architectes de l'information
Phone : +33 (0)9 53 16 02 70 Fax : +33 (0)2 98 050 051

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

[libvirt] [Patch v3] Add VMware Workstation and Player driver

2010-12-08 Thread Jean-Baptiste Rouault
* Changes since v2:
remove unnecessary mutex locks
use vmrun reset soft
convert popen to virCommand
remove duplicate errors
various other fixes

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


[libvirt] [Patch v2] Create file in virFileWriteStr() if it doesn't exist

2010-12-03 Thread Jean-Baptiste Rouault
This patch adds a mode_t parameter to virFileWriteStr().
If mode is different from 0, virFileWriteStr() will try
to create the file if it doesn't exist.
---
 src/network/bridge_driver.c  |8 
 src/node_device/node_device_driver.c |2 +-
 src/util/cgroup.c|2 +-
 src/util/pci.c   |   16 
 src/util/util.c  |   11 ---
 src/util/util.h  |2 +-
 6 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 54890f9..62639e4 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -1024,7 +1024,7 @@ networkReloadIptablesRules(struct network_driver *driver)
 static int
 networkEnableIpForwarding(void)
 {
-return virFileWriteStr(/proc/sys/net/ipv4/ip_forward, 1\n);
+return virFileWriteStr(/proc/sys/net/ipv4/ip_forward, 1\n, 0);
 }
 
 #define SYSCTL_PATH /proc/sys
@@ -1045,7 +1045,7 @@ static int networkDisableIPV6(virNetworkObjPtr network)
 goto cleanup;
 }
 
-if (virFileWriteStr(field, 1)  0) {
+if (virFileWriteStr(field, 1, 0)  0) {
 virReportSystemError(errno,
  _(cannot enable %s), field);
 goto cleanup;
@@ -1057,7 +1057,7 @@ static int networkDisableIPV6(virNetworkObjPtr network)
 goto cleanup;
 }
 
-if (virFileWriteStr(field, 0)  0) {
+if (virFileWriteStr(field, 0, 0)  0) {
 virReportSystemError(errno,
  _(cannot disable %s), field);
 goto cleanup;
@@ -1069,7 +1069,7 @@ static int networkDisableIPV6(virNetworkObjPtr network)
 goto cleanup;
 }
 
-if (virFileWriteStr(field, 1)  0) {
+if (virFileWriteStr(field, 1, 0)  0) {
 virReportSystemError(errno,
  _(cannot enable %s), field);
 goto cleanup;
diff --git a/src/node_device/node_device_driver.c 
b/src/node_device/node_device_driver.c
index 448cfd3..a6c6042 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -454,7 +454,7 @@ nodeDeviceVportCreateDelete(const int parent_host,
 goto cleanup;
 }
 
-if (virFileWriteStr(operation_path, vport_name) == -1) {
+if (virFileWriteStr(operation_path, vport_name, 0) == -1) {
 virReportSystemError(errno,
  _(Write of '%s' to '%s' during 
vport create/delete failed),
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index 2758a8f..3ba6325 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -288,7 +288,7 @@ static int virCgroupSetValueStr(virCgroupPtr group,
 return rc;
 
 VIR_DEBUG(Set value '%s' to '%s', keypath, value);
-rc = virFileWriteStr(keypath, value);
+rc = virFileWriteStr(keypath, value, 0);
 if (rc  0) {
 DEBUG(Failed to write value '%s': %m, value);
 rc = -errno;
diff --git a/src/util/pci.c b/src/util/pci.c
index d38cefa..095ad3f 100644
--- a/src/util/pci.c
+++ b/src/util/pci.c
@@ -849,7 +849,7 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver)
  * bound by the stub.
  */
 pciDriverFile(path, sizeof(path), driver, new_id);
-if (virFileWriteStr(path, dev-id)  0) {
+if (virFileWriteStr(path, dev-id, 0)  0) {
 virReportSystemError(errno,
  _(Failed to add PCI device ID '%s' to %s),
  dev-id, driver);
@@ -862,7 +862,7 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver)
  * your root filesystem.
  */
 pciDeviceFile(path, sizeof(path), dev-name, driver/unbind);
-if (virFileExists(path)  virFileWriteStr(path, dev-name)  0) {
+if (virFileExists(path)  virFileWriteStr(path, dev-name, 0)  0) {
 virReportSystemError(errno,
  _(Failed to unbind PCI device '%s'), dev-name);
 return -1;
@@ -875,7 +875,7 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver)
 if (!virFileLinkPointsTo(path, drvdir)) {
 /* Xen's pciback.ko wants you to use new_slot first */
 pciDriverFile(path, sizeof(path), driver, new_slot);
-if (virFileExists(path)  virFileWriteStr(path, dev-name)  0) {
+if (virFileExists(path)  virFileWriteStr(path, dev-name, 0)  0) {
 virReportSystemError(errno,
  _(Failed to add slot for PCI device '%s' to 
%s),
  dev-name, driver);
@@ -883,7 +883,7 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver)
 }
 
 pciDriverFile(path, sizeof(path), driver, bind);
-if (virFileWriteStr(path, dev-name)  0) {
+if (virFileWriteStr(path, dev-name, 0)  0) {
 virReportSystemError(errno,
  _(Failed to bind PCI device '%s' to %s),
  dev-name, driver);
@@ -895,7 +895,7 @@ 

Re: [libvirt] [Patch v2] Create file in virFileWriteStr() if it doesn't exist

2010-12-03 Thread Jean-Baptiste Rouault
Forget that patch, I didn't receive it by email yet and I saw
Eric patch on the list archive after sending it...

Regards,

-- 
Jean-Baptiste ROUAULT
Ingénieur RD - Diateam : Architectes de l'information
Phone : +33 (0)9 53 16 02 70 Fax : +33 (0)2 98 050 051

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


[libvirt] [PATCH] Create file in virFileWriteStr() if it doesn't exist

2010-12-02 Thread Jean-Baptiste Rouault
This patch adds a virFileWriteStrEx() function with a
third parameter to set the created file permissions.
virFileWriteStr() calls this new function with a
default value for the mode parameter.
---
 src/util/util.c |   11 ---
 src/util/util.h |1 +
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/util/util.c b/src/util/util.c
index a2582aa..82ca9b3 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -1123,14 +1123,19 @@ int virFileReadAll(const char *path, int maxlen, char 
**buf)
 return len;
 }
 
-/* Truncate @path and write @str to it.
+int virFileWriteStr(const char *path, const char *str)
+{
+return virFileWriteStrEx(path, str, S_IRUSR|S_IWUSR);
+}
+
+/* Truncate or create @path and write @str to it.
Return 0 for success, nonzero for failure.
Be careful to preserve any errno value upon failure. */
-int virFileWriteStr(const char *path, const char *str)
+int virFileWriteStrEx(const char *path, const char *str, mode_t mode)
 {
 int fd;
 
-if ((fd = open(path, O_WRONLY|O_TRUNC)) == -1)
+if ((fd = open(path, O_WRONLY|O_TRUNC|O_CREAT, mode)) == -1)
 return -1;
 
 if (safewrite(fd, str, strlen(str))  0) {
diff --git a/src/util/util.h b/src/util/util.h
index a240d87..18ef693 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -96,6 +96,7 @@ int virFileReadLimFD(int fd, int maxlen, char **buf) 
ATTRIBUTE_RETURN_CHECK;
 
 int virFileReadAll(const char *path, int maxlen, char **buf) 
ATTRIBUTE_RETURN_CHECK;
 
+int virFileWriteStrEx(const char *path, const char *str, mode_t mode) 
ATTRIBUTE_RETURN_CHECK;
 int virFileWriteStr(const char *path, const char *str) ATTRIBUTE_RETURN_CHECK;
 
 int virFileMatchesNameSuffix(const char *file,
-- 
1.7.0.4

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


[libvirt] [Patch v2] Add VMware Workstation and Player driver

2010-12-02 Thread Jean-Baptiste Rouault
Many changes since v2 based on Matthias review 
(http://www.redhat.com/archives/libvir-list/2010-November/msg00799.html).
popen() calls will be removed when the new virCommand API is available.

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


[libvirt] Link error since commit c2b3827

2010-12-01 Thread Jean-Baptiste Rouault
I get the following link error since commit c2b3827 :

make[3]: Entering directory `/home/jb/Devel/libvirt/daemon'
  CCLD   libvirtd
../src/.libs/libvirt_driver_qemu.a(libvirt_driver_qemu_la-qemu_driver.o): In 
function `qemudVPAssociatePortProfiles':
/home/jb/Devel/libvirt/src/qemu/qemu_driver.c:11891: undefined reference to 
`vpAssociatePortProfileId'
/home/jb/Devel/libvirt/src/qemu/qemu_driver.c:11908: undefined reference to 
`vpDisassociatePortProfileId'

Macvtap support is disabled and these 2 functions come from macvtap.h.

Regards,

-- 
Jean-Baptiste ROUAULT
Ingénieur RD - Diateam : Architectes de l'information
Phone : +33 (0)9 53 16 02 70 Fax : +33 (0)2 98 050 051

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


[libvirt] [PATCH] Fix warning when macvtap support is disabled

2010-12-01 Thread Jean-Baptiste Rouault
---
 src/qemu/qemu_conf.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index b0343c6..7cd0603 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1689,6 +1689,7 @@ qemudPhysIfaceConnect(virConnectPtr conn,
 (void)qemuCmdFlags;
 (void)driver;
 (void)vmuuid;
+(void)vmop;
 qemuReportError(VIR_ERR_INTERNAL_ERROR,
 %s, _(No support for macvtap device));
 rc = -1;
-- 
1.7.0.4

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


Re: [libvirt] VMware Workstation/Player support

2010-11-12 Thread Jean-Baptiste Rouault
On Tuesday 27 July 2010 20:42:01 Matthias Bolte wrote:
 We'll need to move the VMX handling code from src/esx to src/util,
 because drivers are not allowed to depend on each other.
 
 That should be possible, but will require some refactoring, because
 this code is currently closely entangled with the reset of the ESX
 driver in some places and parts of it are probably quite ESX specific.

Hi,

As of today we have a proof of concept vmware driver with
basic functions implemented (open/close, define/undefine, create, 
start/shutdown...)
However it currently depends on the esx driver for the VMX handling code.
Has anyone started to think of the needed refactoring ? If any help is needed
to refactor I guess I could find some time to work on it.

Jean-Baptiste

-- 
Jean-Baptiste ROUAULT
Ingénieur RD - Diateam : Architectes de l'information
Phone : +33 (0)9 53 16 02 70 Fax : +33 (0)2 98 050 051

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

Re: [libvirt] New save/restore api proposal

2010-11-12 Thread Jean-Baptiste Rouault
On Monday 23 August 2010 17:27:46 Jean-Baptiste Rouault wrote:
 On Monday 23 August 2010 14:51:51 you wrote:
  On Thu, Aug 19, 2010 at 05:12:36PM +0200, Jean-Baptiste Rouault wrote:
   Hello all,
   
   I'd like to add support for save and restore to the OpenVZ and
   VirtualBox drivers because I have to support these operations in the
   application I'm working on.
   
   However, the save/restore API in its current state doesn't fit well to
   our needs. The main problem is that the domain definition is included
   inside the save file. This is problematic because between the save and
   the restore operations, the names of the network interfaces on the host
   side are likely to have changed and we can't modify them before
   restoring the domain.
  
  IMHO a more general approach is to set stable naming for the host
  devices.
 
 This is not possible for us because our application is distributed on
 multiple servers. We have a huge nfs exported folder where we store all
 our guests' disks and private folders. A saved guest which was running on
 one server can be restored on another one so we can't set stable naming
 for the host side.
 
  I really don't think we want to add yet more save/restore functions
  to the API. I'm not sure its even possible to implement those
  proposals with VirtualBox, since it can't save state to an arbitrary
  file.
  
  The API in the VirtualBox SDK is  IProgress IConsole::saveState().
  This does a managed save internally to  vbox. The next time the
  guest is started, it will restore from this image. This maps
  directly to libvirt's virDomainManagedSave() API. The OpenVZ docs
  appear to explicitly forbid any change to the VM configugration
  between time of save  restore. If it didn't forbid config changes,
  then in theory you could call virDomainDefine() after calling
  virDomainManagedSave() but before virDomainCreate() in order ot
  change the config.
 
 The problem of the managed save API for us is that it doesn't allow to set
 a custom save path. We keep save states in each VM's folder so that any of
 our servers is able to access them. Maybe a custom managed save path could
 be specified in a domain's xml and then used instead of the default one ?
 This isn't a problem for VirtualBox because there is the adoptSavedState
 API. For other libvirt drivers I think this shouldn't be too difficult to
 implement.
 
  As for OpenVZ, the vzctl chkpnt  vzctl restore commands look like
  they can map directly to both of the libvirt save/restore APis. The
  original one taking a filename, and the new managed save ones.
  
  Regards,
  Daniel
 
 --
 libvir-list mailing list
 libvir-list@redhat.com
 https://www.redhat.com/mailman/listinfo/libvir-list

Hi,

Sorry to dig up this old thread but I'd like to have some feedback
about adding the possibility to set a custom save path.

Regards,

Jean-Baptiste

-- 
Jean-Baptiste ROUAULT
Ingénieur RD - Diateam : Architectes de l'information
Phone : +33 (0)9 53 16 02 70 Fax : +33 (0)2 98 050 051

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


Re: [libvirt] [PATCH] OpenVZ: add ethernet interface type support

2010-09-01 Thread Jean-Baptiste Rouault
Hi,

Raising this patch to get a review for a potential inclusion in 0.8.4.

Regards,

Jean-Baptiste

 Hi all,
 
 This patch adds support for ethernet interface type to OpenVZ domains
 as stated in this previous message: http://www.redhat.com/archives/libvir-
 list/2010-July/msg00658.html
 
 Regards,
 
 Jean-Baptiste
 

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


Re: [libvirt] New save/restore api proposal

2010-08-23 Thread Jean-Baptiste Rouault
On Monday 23 August 2010 14:51:51 you wrote:
 On Thu, Aug 19, 2010 at 05:12:36PM +0200, Jean-Baptiste Rouault wrote:
  Hello all,
  
  I'd like to add support for save and restore to the OpenVZ and VirtualBox
  drivers because I have to support these operations in the application I'm
  working on.
  
  However, the save/restore API in its current state doesn't fit well to
  our needs. The main problem is that the domain definition is included
  inside the save file. This is problematic because between the save and
  the restore operations, the names of the network interfaces on the host
  side are likely to have changed and we can't modify them before
  restoring the domain.
 
 IMHO a more general approach is to set stable naming for the host
 devices.

This is not possible for us because our application is distributed on multiple 
servers. We have a huge nfs exported folder where we store all our guests' 
disks and private folders. A saved guest which was running on one server can 
be restored on another one so we can't set stable naming for the host side.

 I really don't think we want to add yet more save/restore functions
 to the API. I'm not sure its even possible to implement those
 proposals with VirtualBox, since it can't save state to an arbitrary
 file.
 
 The API in the VirtualBox SDK is  IProgress IConsole::saveState().
 This does a managed save internally to  vbox. The next time the
 guest is started, it will restore from this image. This maps
 directly to libvirt's virDomainManagedSave() API. The OpenVZ docs
 appear to explicitly forbid any change to the VM configugration
 between time of save  restore. If it didn't forbid config changes,
 then in theory you could call virDomainDefine() after calling
 virDomainManagedSave() but before virDomainCreate() in order ot
 change the config.

The problem of the managed save API for us is that it doesn't allow to set a 
custom save path. We keep save states in each VM's folder so that any of our 
servers is able to access them. Maybe a custom managed save path could be 
specified in a domain's xml and then used instead of the default one ? This 
isn't a problem for VirtualBox because there is the adoptSavedState API.
For other libvirt drivers I think this shouldn't be too difficult to implement.

 As for OpenVZ, the vzctl chkpnt  vzctl restore commands look like
 they can map directly to both of the libvirt save/restore APis. The
 original one taking a filename, and the new managed save ones.
 
 Regards,
 Daniel

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


[libvirt] New save/restore api proposal

2010-08-19 Thread Jean-Baptiste Rouault
Hello all,

I'd like to add support for save and restore to the OpenVZ and VirtualBox 
drivers because I have to support these operations in the application I'm 
working on.

However, the save/restore API in its current state doesn't fit well to our 
needs. The main problem is that the domain definition is included inside the 
save file. This is problematic because between the save and the restore 
operations, the names of the network interfaces on the host side are likely to 
have changed and we can't modify them before restoring the domain.

To summarize, what we would like to be able to do is:
- save a domain and undefine it
- update the domain definition to use the new names of host side interfaces
- restore the domain

This is why I would like to add two new functions with the following 
signatures (better names are probably needed):
int virDomainSaveState(virDomainPtr domain, const char *to);
int virDomainRestoreState(virDomainPtr domain, const char *from);

The first one would do the same as virDomainSave but without prepending the 
domain's definition to the save file.
The other function would be able to restore a domain saved by the first one.

What do you think ?

Regards,
Jean-Baptiste

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


[libvirt] [PATCH] OpenVZ: add ethernet interface type support

2010-08-18 Thread Jean-Baptiste Rouault
Hi all,

This patch adds support for ethernet interface type to OpenVZ domains
as stated in this previous message: http://www.redhat.com/archives/libvir-
list/2010-July/msg00658.html

Regards,

Jean-Baptiste
From 140ecba1ee0ed19df8eba5538c0cd7f1fd167ac2 Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Rouault jean-baptiste.roua...@diateam.net
Date: Wed, 18 Aug 2010 16:59:59 +0200
Subject: [PATCH] OpenVZ: add ethernet interface type support

---
 src/openvz/openvz_driver.c |   47 +++
 1 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index d2f91c6..a8dacec 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -741,53 +741,56 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
 virCapabilitiesGenerateMac(driver-caps, host_mac);
 virFormatMacAddr(host_mac, host_macaddr);
 
-if (net-type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
+if (net-type == VIR_DOMAIN_NET_TYPE_BRIDGE ||
+(net-type == VIR_DOMAIN_NET_TYPE_ETHERNET 
+ net-data.ethernet.ipaddr == NULL)) {
 virBuffer buf = VIR_BUFFER_INITIALIZER;
-char *dev_name_ve;
 int veid = openvzGetVEID(vpsid);
 
 //--netif_add ifname[,mac,host_ifname,host_mac]
 ADD_ARG_LIT(--netif_add) ;
 
-/* generate interface name in ve and copy it to options */
-dev_name_ve = openvzGenerateContainerVethName(veid);
-if (dev_name_ve == NULL) {
-   openvzError(VIR_ERR_INTERNAL_ERROR, %s,
-   _(Could not generate eth name for container));
-   rc = -1;
-   goto exit;
+/* if user doesn't specify guest interface name,
+ * then we need to generate it */
+if (net-data.ethernet.dev == NULL) {
+net-data.ethernet.dev = openvzGenerateContainerVethName(veid);
+if (net-data.ethernet.dev == NULL) {
+   openvzError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(Could not generate eth name for container));
+   rc = -1;
+   goto exit;
+}
 }
 
 /* if user doesn't specified host interface name,
  * than we need to generate it */
 if (net-ifname == NULL) {
-net-ifname = openvzGenerateVethName(veid, dev_name_ve);
+net-ifname = openvzGenerateVethName(veid, net-data.ethernet.dev);
 if (net-ifname == NULL) {
openvzError(VIR_ERR_INTERNAL_ERROR, %s,
_(Could not generate veth name));
rc = -1;
-   VIR_FREE(dev_name_ve);
goto exit;
 }
 }
 
-virBufferAdd(buf, dev_name_ve, -1); /* Guest dev */
+virBufferAdd(buf, net-data.ethernet.dev, -1); /* Guest dev */
 virBufferVSprintf(buf, ,%s, macaddr); /* Guest dev mac */
 virBufferVSprintf(buf, ,%s, net-ifname); /* Host dev */
 virBufferVSprintf(buf, ,%s, host_macaddr); /* Host dev mac */
 
-if (driver-version = VZCTL_BRIDGE_MIN_VERSION) {
-virBufferVSprintf(buf, ,%s, net-data.bridge.brname); /* Host bridge */
-} else {
-virBufferVSprintf(configBuf, ifname=%s, dev_name_ve);
-virBufferVSprintf(configBuf, ,mac=%s, macaddr); /* Guest dev mac */
-virBufferVSprintf(configBuf, ,host_ifname=%s, net-ifname); /* Host dev */
-virBufferVSprintf(configBuf, ,host_mac=%s, host_macaddr); /* Host dev mac */
-virBufferVSprintf(configBuf, ,bridge=%s, net-data.bridge.brname); /* Host bridge */
+if (net-type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
+if (driver-version = VZCTL_BRIDGE_MIN_VERSION) {
+virBufferVSprintf(buf, ,%s, net-data.bridge.brname); /* Host bridge */
+} else {
+virBufferVSprintf(configBuf, ifname=%s, net-data.ethernet.dev);
+virBufferVSprintf(configBuf, ,mac=%s, macaddr); /* Guest dev mac */
+virBufferVSprintf(configBuf, ,host_ifname=%s, net-ifname); /* Host dev */
+virBufferVSprintf(configBuf, ,host_mac=%s, host_macaddr); /* Host dev mac */
+virBufferVSprintf(configBuf, ,bridge=%s, net-data.bridge.brname); /* Host bridge */
+}
 }
 
-VIR_FREE(dev_name_ve);
-
 if (!(opt = virBufferContentAndReset(buf)))
 goto no_memory;
 
-- 
1.7.0.4

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

[libvirt] [PATCH] openvzDomainCreateWithFlags: set domain id to the correct value

2010-07-30 Thread Jean-Baptiste Rouault
I'm not sure if it's ok or not to modify dom-id as I did here.

Regards,
Jean-Baptiste
From 7fd011393a80da32949e4aa5468532140d250021 Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Rouault jean-baptiste.roua...@diateam.net
Date: Fri, 30 Jul 2010 10:36:06 +0200
Subject: [PATCH] openvzDomainCreateWithFlags: set domain id to the correct value

When an openvz domain is defined with virDomainDefineXML,
domain id is set to -1. A call to virDomainGetInfo after
starting the domain would then fail because this invalid
id is passed to openvzGetProcessInfo.
---
 src/openvz/openvz_driver.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 98381fb..e5bbdd0 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -992,6 +992,7 @@ openvzDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
 
 vm-pid = strtoI(vm-def-name);
 vm-def-id = vm-pid;
+dom-id = vm-pid;
 vm-state = VIR_DOMAIN_RUNNING;
 ret = 0;
 
-- 
1.7.0.4

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

[libvirt] [PATCH] OpenVZ: implement suspend/resume driver APIs

2010-07-30 Thread Jean-Baptiste Rouault
---
 src/openvz/openvz_driver.c |   84 ++-
 1 files changed, 82 insertions(+), 2 deletions(-)

diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index e5bbdd0..bdc0e92 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -503,6 +503,86 @@ static void openvzSetProgramSentinal(const char **prog, 
const char *key)
 }
 }
 
+static int openvzDomainSuspend(virDomainPtr dom) {
+struct openvz_driver *driver = dom-conn-privateData;
+virDomainObjPtr vm;
+const char *prog[] = {VZCTL, --quiet, chkpnt, PROGRAM_SENTINAL, 
--suspend, NULL};
+int ret = -1;
+
+openvzDriverLock(driver);
+vm = virDomainFindByUUID(driver-domains, dom-uuid);
+openvzDriverUnlock(driver);
+
+if (!vm) {
+openvzError(VIR_ERR_INVALID_DOMAIN, %s,
+_(no domain with matching uuid));
+goto cleanup;
+}
+
+if (!virDomainObjIsActive(vm)) {
+openvzError(VIR_ERR_OPERATION_INVALID, %s,
+_(Domain is not running));
+goto cleanup;
+}
+
+if (vm-state != VIR_DOMAIN_PAUSED) {
+openvzSetProgramSentinal(prog, vm-def-name);
+if (virRun(prog, NULL)  0) {
+openvzError(VIR_ERR_OPERATION_FAILED, %s,
+_(Suspend operation failed));
+goto cleanup;
+}
+vm-state = VIR_DOMAIN_PAUSED;
+}
+
+ret = 0;
+
+cleanup:
+if (vm)
+virDomainObjUnlock(vm);
+return ret;
+}
+
+static int openvzDomainResume(virDomainPtr dom) {
+  struct openvz_driver *driver = dom-conn-privateData;
+  virDomainObjPtr vm;
+  const char *prog[] = {VZCTL, --quiet, chkpnt, PROGRAM_SENTINAL, 
--resume, NULL};
+  int ret = -1;
+
+  openvzDriverLock(driver);
+  vm = virDomainFindByUUID(driver-domains, dom-uuid);
+  openvzDriverUnlock(driver);
+
+  if (!vm) {
+  openvzError(VIR_ERR_INVALID_DOMAIN, %s,
+  _(no domain with matching uuid));
+  goto cleanup;
+  }
+
+  if (!virDomainObjIsActive(vm)) {
+  openvzError(VIR_ERR_OPERATION_INVALID, %s,
+  _(Domain is not running));
+  goto cleanup;
+  }
+
+  if (vm-state == VIR_DOMAIN_PAUSED) {
+  openvzSetProgramSentinal(prog, vm-def-name);
+  if (virRun(prog, NULL)  0) {
+  openvzError(VIR_ERR_OPERATION_FAILED, %s,
+  _(Resume operation failed));
+  goto cleanup;
+  }
+  vm-state = VIR_DOMAIN_RUNNING;
+  }
+
+  ret = 0;
+
+cleanup:
+  if (vm)
+  virDomainObjUnlock(vm);
+  return ret;
+}
+
 static int openvzDomainShutdown(virDomainPtr dom) {
 struct openvz_driver *driver = dom-conn-privateData;
 virDomainObjPtr vm;
@@ -1491,8 +1571,8 @@ static virDriver openvzDriver = {
 openvzDomainLookupByID, /* domainLookupByID */
 openvzDomainLookupByUUID, /* domainLookupByUUID */
 openvzDomainLookupByName, /* domainLookupByName */
-NULL, /* domainSuspend */
-NULL, /* domainResume */
+openvzDomainSuspend, /* domainSuspend */
+openvzDomainResume, /* domainResume */
 openvzDomainShutdown, /* domainShutdown */
 openvzDomainReboot, /* domainReboot */
 openvzDomainShutdown, /* domainDestroy */
-- 
1.7.0.4

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


[libvirt] OpenVZ ethernet interface type

2010-07-28 Thread Jean-Baptiste Rouault
Hello,

I'd like to be able to add interfaces to OpenVZ guests like the following
vzctl command does : vzctl set 100 --netif_add eth0,00:11:22:33:44:55,tap0
Here, eth0 is the guest interface name, and tap0 the host interface name.

This is currently not supported by libvirt so I'd like to implement it.
In terms of domain XML I think it would be something like:
  interface type='ethernet'
mac address='00:11:22:33:44:55'/
source dev='eth0'/
target dev='tap0'/
  /interface

Currently the OpenVZ driver calls vzctl set 100 --ipadd when the interface 
type is ethernet and the ip address attribute isn't empty.
Does it seem ok to use --netif_add for ethernet interfaces when there is no ip 
defined ?

Regards,

Jean-Baptiste Rouault

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


[libvirt] VMware Workstation/Player support

2010-07-27 Thread Jean-Baptiste Rouault
Hi all,

I'm working on the hynesim project (http://www.hynesim.org
http://blog.hynesim.org).
We are going to add VMware Workstation support to hynesim,
so we would like to contribute to the development of a libvirt driver.

There probably are multiple ways of doing this, one of them could
be to use the VIX C API provided by VMware :
http://www.vmware.com/support/developer/vix-api/
However, the VIX license seems to be quite restrictive :
http://www.vmware.com/download/eula/vixapi_eula.html
I'm not a license expert so I don't know if this license forbids
using the API in software like libvirt.

Another possibility could be to run VMware command line tools
from libvirt to control guests.

As Daniel P. Berrange stated on IRC yesterday, the vmx - XML
conversion code can be reused from the ESX driver.

I'd like to have your opinion about the best to implement this
VMware Workstation driver.

Regards,

Jean-Baptiste Rouault

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