~serge-hallyn/ubuntu/oneiric/libvirt/fix-shutdown

« back to all changes in this revision

Viewing changes to docs/api_extension/0006-make-old-API-trivially-wrap-to-new-API.patch

  • Committer: Bazaar Package Importer
  • Author(s): Serge Hallyn
  • Date: 2010-11-02 16:26:51 UTC
  • mfrom: (1.2.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20101102162651-aq8tnbz58mdf01bf
Tags: 0.8.5-0ubuntu1
* New upstream release.
* Removed a slew of patches which have been
  applied upstream since 0.8.3.
  - 9012-apparmor-extra-tests.patch
  - 9013-apparmor-chardev.patch
  - 9015-Add-ubd-to-the-list-of-disk-prefixes.patch
  - 9016-Close-fd-s-of-persistent-tap-devices.patch
  - 9017-Make-sure-all-command-line-arguments-get-passed-to-U.patch
  - 9018-Make-umlConnectTapDevice-ask-brAddTap-for-a-persiste.patch
  - 9019-uml-fix-logic-bug-in-checking-reply-length.patch
  - 9021-Allow-chardev-of-type-file-for-UML-domains.patch
  - 9022-Rename-qemudShrinkDisks-to-virDomainDiskRemove-and-m.patch
  - 9023-Support-virDomainAttachDevice-and-virDomainDetachDev.patch
  - 9024-Explicitly-pass-uml_dir-argument-to-user-mode-linux.patch
  - 9025-Add-nwfilter-support-to-UML-driver.patch
  - 9026-Rebuild-network-filter-for-UML-guests-on-updates.patch
  - 9027-Make-newfilter-xml-transformations-endian-safe.patch
  - 9028-lp628055.patch
* Updated 9002-better_default_uri_virsh.patch to use vshStrdup,
  as now required in that file.  (use of strdup now causes compilation
  to fail)
* Removed 9008-run-as-root-by-default.patch, which has not been
  applied for awhile now, with no ill effects.
* Simple refresh of:
  - 0001-remove-RHism.diff.patch
  - 0003-allow-libvirt-group-to-access-the-socket.patch
  - 0004-fix-Debian-specific-path-to-hvm-loader.patch
  - 0006-patch-qemuMonitorTextGetMigrationStatus-to-intercept.patch
  - 9000-delayed_iff_up_bridge.patch
  - 9001-dont_clobber_existing_bridges.patch
  - 9003-better-default-arch.patch
  - 9004-libvirtd-group-name.patch
  - 9005-increase-unix-socket-timeout.patch
  - 9006-default-config-test-case.patch
  - 9009-autodetect-nc-params.patch
  - 9010-dont-disable-ipv6.patch
  - 9011-move-ebtables-script.patch
  - 9014-skip-nodeinfotest.patch
  - 9020-lp545795.patch
* Create a patch to include stdint.h so lxc_container.h, which
  #includes linux/fs.h, doesn't trip up on undefined uint64_t.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From 50c51f13e2af04afac46e181c4ed62581545a488 Mon Sep 17 00:00:00 2001
 
2
From: Eric Blake <eblake@redhat.com>
 
3
Date: Mon, 27 Sep 2010 16:37:53 -0600
 
4
Subject: [PATCH 06/15] vcpu: make old API trivially wrap to new API
 
5
 
 
6
Note - this wrapping is completely mechanical; the old API will
 
7
function identically, since the new API validates that the exact
 
8
same flags are provided by the old API.  On a per-driver basis,
 
9
it may make sense to have the old API pass a different set of flags,
 
10
but that should be done in the per-driver patch that implements
 
11
the full range of flag support in the new API.
 
12
 
 
13
* src/esx/esx_driver.c (esxDomainSetVcpus, escDomainGetMaxVpcus):
 
14
Move guts...
 
15
(esxDomainSetVcpusFlags, esxDomainGetVcpusFlags): ...to new
 
16
functions.
 
17
(esxDriver): Trivially support the new API.
 
18
* src/openvz/openvz_driver.c (openvzDomainSetVcpus)
 
19
(openvzDomainSetVcpusFlags, openvzDomainGetMaxVcpus)
 
20
(openvzDomainGetVcpusFlags, openvzDriver): Likewise.
 
21
* src/phyp/phyp_driver.c (phypDomainSetCPU)
 
22
(phypDomainSetVcpusFlags, phypGetLparCPUMAX)
 
23
(phypDomainGetVcpusFlags, phypDriver): Likewise.
 
24
* src/qemu/qemu_driver.c (qemudDomainSetVcpus)
 
25
(qemudDomainSetVcpusFlags, qemudDomainGetMaxVcpus)
 
26
(qemudDomainGetVcpusFlags, qemuDriver): Likewise.
 
27
* src/test/test_driver.c (testSetVcpus, testDomainSetVcpusFlags)
 
28
(testDomainGetMaxVcpus, testDomainGetVcpusFlags, testDriver):
 
29
Likewise.
 
30
* src/vbox/vbox_tmpl.c (vboxDomainSetVcpus)
 
31
(vboxDomainSetVcpusFlags, virDomainGetMaxVcpus)
 
32
(virDomainGetVcpusFlags, virDriver): Likewise.
 
33
* src/xen/xen_driver.c (xenUnifiedDomainSetVcpus)
 
34
(xenUnifiedDomainSetVcpusFlags, xenUnifiedDomainGetMaxVcpus)
 
35
(xenUnifiedDomainGetVcpusFlags, xenUnifiedDriver): Likewise.
 
36
* src/xenapi/xenapi_driver.c (xenapiDomainSetVcpus)
 
37
(xenapiDomainSetVcpusFlags, xenapiDomainGetMaxVcpus)
 
38
(xenapiDomainGetVcpusFlags, xenapiDriver): Likewise.
 
39
(xenapiError): New helper macro.
 
40
---
 
41
 src/esx/esx_driver.c       |   32 +++++++++++++++++++---
 
42
 src/openvz/openvz_driver.c |   34 +++++++++++++++++++++---
 
43
 src/phyp/phyp_driver.c     |   32 ++++++++++++++++++++---
 
44
 src/qemu/qemu_driver.c     |   38 +++++++++++++++++++++++++---
 
45
 src/test/test_driver.c     |   36 ++++++++++++++++++++++---
 
46
 src/vbox/vbox_tmpl.c       |   36 +++++++++++++++++++++++---
 
47
 src/xen/xen_driver.c       |   34 ++++++++++++++++++++++---
 
48
 src/xenapi/xenapi_driver.c |   60 ++++++++++++++++++++++++++++++++++++++------
 
49
 8 files changed, 263 insertions(+), 39 deletions(-)
 
50
 
 
51
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
 
52
index 2a32374..b3e1284 100644
 
53
--- a/src/esx/esx_driver.c
 
54
+++ b/src/esx/esx_driver.c
 
55
@@ -2384,7 +2384,8 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
 
56
 
 
57
 
 
58
 static int
 
59
-esxDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
 
60
+esxDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus,
 
61
+                       unsigned int flags)
 
62
 {
 
63
     int result = -1;
 
64
     esxPrivate *priv = domain->conn->privateData;
 
65
@@ -2394,6 +2395,11 @@ esxDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
 
66
     esxVI_ManagedObjectReference *task = NULL;
 
67
     esxVI_TaskInfoState taskInfoState;
 
68
 
 
69
+    if (flags != VIR_DOMAIN_VCPU_LIVE) {
 
70
+        ESX_ERROR(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
 
71
+        return -1;
 
72
+    }
 
73
+
 
74
     if (nvcpus < 1) {
 
75
         ESX_ERROR(VIR_ERR_INVALID_ARG, "%s",
 
76
                   _("Requested number of virtual CPUs must at least be 1"));
 
77
@@ -2453,15 +2459,26 @@ esxDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
 
78
 }
 
79
 
 
80
 
 
81
+static int
 
82
+esxDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
 
83
+{
 
84
+    return esxDomainSetVcpusFlags(domain, nvcpus, VIR_DOMAIN_VCPU_LIVE);
 
85
+}
 
86
+
 
87
 
 
88
 static int
 
89
-esxDomainGetMaxVcpus(virDomainPtr domain)
 
90
+esxDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
 
91
 {
 
92
     esxPrivate *priv = domain->conn->privateData;
 
93
     esxVI_String *propertyNameList = NULL;
 
94
     esxVI_ObjectContent *hostSystem = NULL;
 
95
     esxVI_DynamicProperty *dynamicProperty = NULL;
 
96
 
 
97
+    if (flags != (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
 
98
+        ESX_ERROR(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
 
99
+        return -1;
 
100
+    }
 
101
+
 
102
     if (priv->maxVcpus > 0) {
 
103
         return priv->maxVcpus;
 
104
     }
 
105
@@ -2507,7 +2524,12 @@ esxDomainGetMaxVcpus(virDomainPtr domain)
 
106
     return priv->maxVcpus;
 
107
 }
 
108
 
 
109
-
 
110
+static int
 
111
+esxDomainGetMaxVcpus(virDomainPtr domain)
 
112
+{
 
113
+    return esxDomainGetVcpusFlags(domain, (VIR_DOMAIN_VCPU_LIVE |
 
114
+                                           VIR_DOMAIN_VCPU_MAXIMUM));
 
115
+}
 
116
 
 
117
 static char *
 
118
 esxDomainDumpXML(virDomainPtr domain, int flags)
 
119
@@ -4160,8 +4182,8 @@ static virDriver esxDriver = {
 
120
     NULL,                            /* domainRestore */
 
121
     NULL,                            /* domainCoreDump */
 
122
     esxDomainSetVcpus,               /* domainSetVcpus */
 
123
-    NULL,                            /* domainSetVcpusFlags */
 
124
-    NULL,                            /* domainGetVcpusFlags */
 
125
+    esxDomainSetVcpusFlags,          /* domainSetVcpusFlags */
 
126
+    esxDomainGetVcpusFlags,          /* domainGetVcpusFlags */
 
127
     NULL,                            /* domainPinVcpu */
 
128
     NULL,                            /* domainGetVcpus */
 
129
     esxDomainGetMaxVcpus,            /* domainGetMaxVcpus */
 
130
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
 
131
index 9d19aeb..0f3cfdf 100644
 
132
--- a/src/openvz/openvz_driver.c
 
133
+++ b/src/openvz/openvz_driver.c
 
134
@@ -67,7 +67,6 @@
 
135
 static int openvzGetProcessInfo(unsigned long long *cpuTime, int vpsid);
 
136
 static int openvzGetMaxVCPUs(virConnectPtr conn, const char *type);
 
137
 static int openvzDomainGetMaxVcpus(virDomainPtr dom);
 
138
-static int openvzDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus);
 
139
 static int openvzDomainSetVcpusInternal(virDomainObjPtr vm,
 
140
                                         unsigned int nvcpus);
 
141
 static int openvzDomainSetMemoryInternal(virDomainObjPtr vm,
 
142
@@ -1211,11 +1210,24 @@ static int openvzGetMaxVCPUs(virConnectPtr conn ATTRIBUTE_UNUSED,
 
143
     return -1;
 
144
 }
 
145
 
 
146
+static int
 
147
+openvzDomainGetVcpusFlags(virDomainPtr dom ATTRIBUTE_UNUSED,
 
148
+                          unsigned int flags)
 
149
+{
 
150
+    if (flags != (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
 
151
+        openvzError(VIR_ERR_INVALID_ARG, _("unsupported flags (0x%x)"), flags);
 
152
+        return -1;
 
153
+    }
 
154
 
 
155
-static int openvzDomainGetMaxVcpus(virDomainPtr dom ATTRIBUTE_UNUSED) {
 
156
     return openvzGetMaxVCPUs(NULL, "openvz");
 
157
 }
 
158
 
 
159
+static int openvzDomainGetMaxVcpus(virDomainPtr dom)
 
160
+{
 
161
+    return openvzDomainGetVcpusFlags(dom, (VIR_DOMAIN_VCPU_LIVE |
 
162
+                                           VIR_DOMAIN_VCPU_MAXIMUM));
 
163
+}
 
164
+
 
165
 static int openvzDomainSetVcpusInternal(virDomainObjPtr vm,
 
166
                                         unsigned int nvcpus)
 
167
 {
 
168
@@ -1241,12 +1253,18 @@ static int openvzDomainSetVcpusInternal(virDomainObjPtr vm,
 
169
     return 0;
 
170
 }
 
171
 
 
172
-static int openvzDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus)
 
173
+static int openvzDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
 
174
+                                     unsigned int flags)
 
175
 {
 
176
     virDomainObjPtr         vm;
 
177
     struct openvz_driver   *driver = dom->conn->privateData;
 
178
     int                     ret = -1;
 
179
 
 
180
+    if (flags != VIR_DOMAIN_VCPU_LIVE) {
 
181
+        openvzError(VIR_ERR_INVALID_ARG, _("unsupported flags (0x%x)"), flags);
 
182
+        return -1;
 
183
+    }
 
184
+
 
185
     openvzDriverLock(driver);
 
186
     vm = virDomainFindByUUID(&driver->domains, dom->uuid);
 
187
     openvzDriverUnlock(driver);
 
188
@@ -1272,6 +1290,12 @@ cleanup:
 
189
     return ret;
 
190
 }
 
191
 
 
192
+static int
 
193
+openvzDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus)
 
194
+{
 
195
+    return openvzDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_VCPU_LIVE);
 
196
+}
 
197
+
 
198
 static virDrvOpenStatus openvzOpen(virConnectPtr conn,
 
199
                                    virConnectAuthPtr auth ATTRIBUTE_UNUSED,
 
200
                                    int flags ATTRIBUTE_UNUSED)
 
201
@@ -1590,8 +1614,8 @@ static virDriver openvzDriver = {
 
202
     NULL, /* domainRestore */
 
203
     NULL, /* domainCoreDump */
 
204
     openvzDomainSetVcpus, /* domainSetVcpus */
 
205
-    NULL, /* domainSetVcpusFlags */
 
206
-    NULL, /* domainGetVcpusFlags */
 
207
+    openvzDomainSetVcpusFlags, /* domainSetVcpusFlags */
 
208
+    openvzDomainGetVcpusFlags, /* domainGetVcpusFlags */
 
209
     NULL, /* domainPinVcpu */
 
210
     NULL, /* domainGetVcpus */
 
211
     openvzDomainGetMaxVcpus, /* domainGetMaxVcpus */
 
212
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
 
213
index 6e0a5e9..e284ae0 100644
 
214
--- a/src/phyp/phyp_driver.c
 
215
+++ b/src/phyp/phyp_driver.c
 
216
@@ -1497,15 +1497,27 @@ phypGetLparCPU(virConnectPtr conn, const char *managed_system, int lpar_id)
 
217
 }
 
218
 
 
219
 static int
 
220
-phypGetLparCPUMAX(virDomainPtr dom)
 
221
+phypDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
 
222
 {
 
223
     phyp_driverPtr phyp_driver = dom->conn->privateData;
 
224
     char *managed_system = phyp_driver->managed_system;
 
225
 
 
226
+    if (flags != (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
 
227
+        PHYP_ERROR(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
 
228
+        return -1;
 
229
+    }
 
230
+
 
231
     return phypGetLparCPUGeneric(dom->conn, managed_system, dom->id, 1);
 
232
 }
 
233
 
 
234
 static int
 
235
+phypGetLparCPUMAX(virDomainPtr dom)
 
236
+{
 
237
+    return phypDomainGetVcpusFlags(dom, (VIR_DOMAIN_VCPU_LIVE |
 
238
+                                         VIR_DOMAIN_VCPU_MAXIMUM));
 
239
+}
 
240
+
 
241
+static int
 
242
 phypGetRemoteSlot(virConnectPtr conn, const char *managed_system,
 
243
                   const char *lpar_name)
 
244
 {
 
245
@@ -3831,7 +3843,8 @@ phypConnectGetCapabilities(virConnectPtr conn)
 
246
 }
 
247
 
 
248
 static int
 
249
-phypDomainSetCPU(virDomainPtr dom, unsigned int nvcpus)
 
250
+phypDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
 
251
+                        unsigned int flags)
 
252
 {
 
253
     ConnectionData *connection_data = dom->conn->networkPrivateData;
 
254
     phyp_driverPtr phyp_driver = dom->conn->privateData;
 
255
@@ -3846,6 +3859,11 @@ phypDomainSetCPU(virDomainPtr dom, unsigned int nvcpus)
 
256
     unsigned int amount = 0;
 
257
     virBuffer buf = VIR_BUFFER_INITIALIZER;
 
258
 
 
259
+    if (flags != VIR_DOMAIN_VCPU_LIVE) {
 
260
+        PHYP_ERROR(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
 
261
+        return -1;
 
262
+    }
 
263
+
 
264
     if ((ncpus = phypGetLparCPU(dom->conn, managed_system, dom->id)) == 0)
 
265
         return 0;
 
266
 
 
267
@@ -3891,6 +3909,12 @@ phypDomainSetCPU(virDomainPtr dom, unsigned int nvcpus)
 
268
 
 
269
 }
 
270
 
 
271
+static int
 
272
+phypDomainSetCPU(virDomainPtr dom, unsigned int nvcpus)
 
273
+{
 
274
+    return phypDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_VCPU_LIVE);
 
275
+}
 
276
+
 
277
 static virDrvOpenStatus
 
278
 phypVIOSDriverOpen(virConnectPtr conn,
 
279
                    virConnectAuthPtr auth ATTRIBUTE_UNUSED,
 
280
@@ -3941,8 +3965,8 @@ static virDriver phypDriver = {
 
281
     NULL,                       /* domainRestore */
 
282
     NULL,                       /* domainCoreDump */
 
283
     phypDomainSetCPU,           /* domainSetVcpus */
 
284
-    NULL,                       /* domainSetVcpusFlags */
 
285
-    NULL,                       /* domainGetVcpusFlags */
 
286
+    phypDomainSetVcpusFlags,    /* domainSetVcpusFlags */
 
287
+    phypDomainGetVcpusFlags,    /* domainGetVcpusFlags */
 
288
     NULL,                       /* domainPinVcpu */
 
289
     NULL,                       /* domainGetVcpus */
 
290
     phypGetLparCPUMAX,          /* domainGetMaxVcpus */
 
291
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
 
292
index 3d17e04..7a2ea8f 100644
 
293
--- a/src/qemu/qemu_driver.c
 
294
+++ b/src/qemu/qemu_driver.c
 
295
@@ -5934,13 +5934,22 @@ unsupported:
 
296
 }
 
297
 
 
298
 
 
299
-static int qemudDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) {
 
300
+static int
 
301
+qemudDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
 
302
+                         unsigned int flags)
 
303
+{
 
304
     struct qemud_driver *driver = dom->conn->privateData;
 
305
     virDomainObjPtr vm;
 
306
     const char * type;
 
307
     int max;
 
308
     int ret = -1;
 
309
 
 
310
+    if (flags != VIR_DOMAIN_VCPU_LIVE) {
 
311
+        qemuReportError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"),
 
312
+                        flags);
 
313
+        return -1;
 
314
+    }
 
315
+
 
316
     qemuDriverLock(driver);
 
317
     vm = virDomainFindByUUID(&driver->domains, dom->uuid);
 
318
     qemuDriverUnlock(driver);
 
319
@@ -5994,6 +6003,12 @@ cleanup:
 
320
     return ret;
 
321
 }
 
322
 
 
323
+static int
 
324
+qemudDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus)
 
325
+{
 
326
+    return qemudDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_VCPU_LIVE);
 
327
+}
 
328
+
 
329
 
 
330
 static int
 
331
 qemudDomainPinVcpu(virDomainPtr dom,
 
332
@@ -6150,12 +6165,20 @@ cleanup:
 
333
 }
 
334
 
 
335
 
 
336
-static int qemudDomainGetMaxVcpus(virDomainPtr dom) {
 
337
+static int
 
338
+qemudDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
 
339
+{
 
340
     struct qemud_driver *driver = dom->conn->privateData;
 
341
     virDomainObjPtr vm;
 
342
     const char *type;
 
343
     int ret = -1;
 
344
 
 
345
+    if (flags != (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
 
346
+        qemuReportError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"),
 
347
+                        flags);
 
348
+        return -1;
 
349
+    }
 
350
+
 
351
     qemuDriverLock(driver);
 
352
     vm = virDomainFindByUUID(&driver->domains, dom->uuid);
 
353
     qemuDriverUnlock(driver);
 
354
@@ -6183,6 +6206,13 @@ cleanup:
 
355
     return ret;
 
356
 }
 
357
 
 
358
+static int
 
359
+qemudDomainGetMaxVcpus(virDomainPtr dom)
 
360
+{
 
361
+    return qemudDomainGetVcpusFlags(dom, (VIR_DOMAIN_VCPU_LIVE |
 
362
+                                          VIR_DOMAIN_VCPU_MAXIMUM));
 
363
+}
 
364
+
 
365
 static int qemudDomainGetSecurityLabel(virDomainPtr dom, virSecurityLabelPtr seclabel)
 
366
 {
 
367
     struct qemud_driver *driver = (struct qemud_driver *)dom->conn->privateData;
 
368
@@ -12938,8 +12968,8 @@ static virDriver qemuDriver = {
 
369
     qemudDomainRestore, /* domainRestore */
 
370
     qemudDomainCoreDump, /* domainCoreDump */
 
371
     qemudDomainSetVcpus, /* domainSetVcpus */
 
372
-    NULL, /* domainSetVcpusFlags */
 
373
-    NULL, /* domainGetVcpusFlags */
 
374
+    qemudDomainSetVcpusFlags, /* domainSetVcpusFlags */
 
375
+    qemudDomainGetVcpusFlags, /* domainGetVcpusFlags */
 
376
     qemudDomainPinVcpu, /* domainPinVcpu */
 
377
     qemudDomainGetVcpus, /* domainGetVcpus */
 
378
     qemudDomainGetMaxVcpus, /* domainGetMaxVcpus */
 
379
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
 
380
index 6a00558..b70c80d 100644
 
381
--- a/src/test/test_driver.c
 
382
+++ b/src/test/test_driver.c
 
383
@@ -2029,17 +2029,37 @@ cleanup:
 
384
     return ret;
 
385
 }
 
386
 
 
387
-static int testDomainGetMaxVcpus(virDomainPtr domain)
 
388
+static int
 
389
+testDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
 
390
 {
 
391
+    if (flags != (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
 
392
+        testError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
 
393
+        return -1;
 
394
+    }
 
395
+
 
396
     return testGetMaxVCPUs(domain->conn, "test");
 
397
 }
 
398
 
 
399
-static int testSetVcpus(virDomainPtr domain,
 
400
-                        unsigned int nrCpus) {
 
401
+static int
 
402
+testDomainGetMaxVcpus(virDomainPtr domain)
 
403
+{
 
404
+    return testDomainGetVcpusFlags(domain, (VIR_DOMAIN_VCPU_LIVE |
 
405
+                                            VIR_DOMAIN_VCPU_MAXIMUM));
 
406
+}
 
407
+
 
408
+static int
 
409
+testDomainSetVcpusFlags(virDomainPtr domain, unsigned int nrCpus,
 
410
+                        unsigned int flags)
 
411
+{
 
412
     testConnPtr privconn = domain->conn->privateData;
 
413
     virDomainObjPtr privdom = NULL;
 
414
     int ret = -1, maxvcpus;
 
415
 
 
416
+    if (flags != VIR_DOMAIN_VCPU_LIVE) {
 
417
+        testError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
 
418
+        return -1;
 
419
+    }
 
420
+
 
421
     /* Do this first before locking */
 
422
     maxvcpus = testDomainGetMaxVcpus(domain);
 
423
     if (maxvcpus < 0)
 
424
@@ -2082,6 +2102,12 @@ cleanup:
 
425
     return ret;
 
426
 }
 
427
 
 
428
+static int
 
429
+testSetVcpus(virDomainPtr domain, unsigned int nrCpus)
 
430
+{
 
431
+    return testDomainSetVcpusFlags(domain, nrCpus, VIR_DOMAIN_VCPU_LIVE);
 
432
+}
 
433
+
 
434
 static int testDomainGetVcpus(virDomainPtr domain,
 
435
                               virVcpuInfoPtr info,
 
436
                               int maxinfo,
 
437
@@ -5260,8 +5286,8 @@ static virDriver testDriver = {
 
438
     testDomainRestore, /* domainRestore */
 
439
     testDomainCoreDump, /* domainCoreDump */
 
440
     testSetVcpus, /* domainSetVcpus */
 
441
-    NULL, /* domainSetVcpusFlags */
 
442
-    NULL, /* domainGetVcpusFlags */
 
443
+    testDomainSetVcpusFlags, /* domainSetVcpusFlags */
 
444
+    testDomainGetVcpusFlags, /* domainGetVcpusFlags */
 
445
     testDomainPinVcpu, /* domainPinVcpu */
 
446
     testDomainGetVcpus, /* domainGetVcpus */
 
447
     testDomainGetMaxVcpus, /* domainGetMaxVcpus */
 
448
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
 
449
index cb9193a..0cbe8b3 100644
 
450
--- a/src/vbox/vbox_tmpl.c
 
451
+++ b/src/vbox/vbox_tmpl.c
 
452
@@ -1839,13 +1839,21 @@ cleanup:
 
453
     return ret;
 
454
 }
 
455
 
 
456
-static int vboxDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) {
 
457
+static int
 
458
+vboxDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
 
459
+                        unsigned int flags)
 
460
+{
 
461
     VBOX_OBJECT_CHECK(dom->conn, int, -1);
 
462
     IMachine *machine    = NULL;
 
463
     vboxIID  *iid        = NULL;
 
464
     PRUint32  CPUCount   = nvcpus;
 
465
     nsresult rc;
 
466
 
 
467
+    if (flags != VIR_DOMAIN_VCPU_LIVE) {
 
468
+        vboxError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
 
469
+        return -1;
 
470
+    }
 
471
+
 
472
 #if VBOX_API_VERSION == 2002
 
473
     if (VIR_ALLOC(iid) < 0) {
 
474
         virReportOOMError();
 
475
@@ -1887,11 +1895,24 @@ cleanup:
 
476
     return ret;
 
477
 }
 
478
 
 
479
-static int vboxDomainGetMaxVcpus(virDomainPtr dom) {
 
480
+static int
 
481
+vboxDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus)
 
482
+{
 
483
+    return vboxDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_VCPU_LIVE);
 
484
+}
 
485
+
 
486
+static int
 
487
+vboxDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
 
488
+{
 
489
     VBOX_OBJECT_CHECK(dom->conn, int, -1);
 
490
     ISystemProperties *systemProperties = NULL;
 
491
     PRUint32 maxCPUCount = 0;
 
492
 
 
493
+    if (flags != (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
 
494
+        vboxError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags);
 
495
+        return -1;
 
496
+    }
 
497
+
 
498
     /* Currently every domain supports the same number of max cpus
 
499
      * as that supported by vbox and thus take it directly from
 
500
      * the systemproperties.
 
501
@@ -1909,6 +1930,13 @@ static int vboxDomainGetMaxVcpus(virDomainPtr dom) {
 
502
     return ret;
 
503
 }
 
504
 
 
505
+static int
 
506
+vboxDomainGetMaxVcpus(virDomainPtr dom)
 
507
+{
 
508
+    return vboxDomainGetVcpusFlags(dom, (VIR_DOMAIN_VCPU_LIVE |
 
509
+                                         VIR_DOMAIN_VCPU_MAXIMUM));
 
510
+}
 
511
+
 
512
 static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
 
513
     VBOX_OBJECT_CHECK(dom->conn, char *, NULL);
 
514
     virDomainDefPtr def  = NULL;
 
515
@@ -8267,8 +8295,8 @@ virDriver NAME(Driver) = {
 
516
     NULL, /* domainRestore */
 
517
     NULL, /* domainCoreDump */
 
518
     vboxDomainSetVcpus, /* domainSetVcpus */
 
519
-    NULL, /* domainSetVcpusFlags */
 
520
-    NULL, /* domainGetVcpusFlags */
 
521
+    vboxDomainSetVcpusFlags, /* domainSetVcpusFlags */
 
522
+    vboxDomainGetVcpusFlags, /* domainGetVcpusFlags */
 
523
     NULL, /* domainPinVcpu */
 
524
     NULL, /* domainGetVcpus */
 
525
     vboxDomainGetMaxVcpus, /* domainGetMaxVcpus */
 
526
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
 
527
index 7d67ced..d6c9c57 100644
 
528
--- a/src/xen/xen_driver.c
 
529
+++ b/src/xen/xen_driver.c
 
530
@@ -1069,11 +1069,18 @@ xenUnifiedDomainCoreDump (virDomainPtr dom, const char *to, int flags)
 
531
 }
 
532
 
 
533
 static int
 
534
-xenUnifiedDomainSetVcpus (virDomainPtr dom, unsigned int nvcpus)
 
535
+xenUnifiedDomainSetVcpusFlags (virDomainPtr dom, unsigned int nvcpus,
 
536
+                               unsigned int flags)
 
537
 {
 
538
     GET_PRIVATE(dom->conn);
 
539
     int i;
 
540
 
 
541
+    if (flags != VIR_DOMAIN_VCPU_LIVE) {
 
542
+        xenUnifiedError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"),
 
543
+                        flags);
 
544
+        return -1;
 
545
+    }
 
546
+
 
547
     /* Try non-hypervisor methods first, then hypervisor direct method
 
548
      * as a last resort.
 
549
      */
 
550
@@ -1093,6 +1100,12 @@ xenUnifiedDomainSetVcpus (virDomainPtr dom, unsigned int nvcpus)
 
551
 }
 
552
 
 
553
 static int
 
554
+xenUnifiedDomainSetVcpus (virDomainPtr dom, unsigned int nvcpus)
 
555
+{
 
556
+    return xenUnifiedDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_VCPU_LIVE);
 
557
+}
 
558
+
 
559
+static int
 
560
 xenUnifiedDomainPinVcpu (virDomainPtr dom, unsigned int vcpu,
 
561
                          unsigned char *cpumap, int maplen)
 
562
 {
 
563
@@ -1126,11 +1139,17 @@ xenUnifiedDomainGetVcpus (virDomainPtr dom,
 
564
 }
 
565
 
 
566
 static int
 
567
-xenUnifiedDomainGetMaxVcpus (virDomainPtr dom)
 
568
+xenUnifiedDomainGetVcpusFlags (virDomainPtr dom, unsigned int flags)
 
569
 {
 
570
     GET_PRIVATE(dom->conn);
 
571
     int i, ret;
 
572
 
 
573
+    if (flags != (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
 
574
+        xenUnifiedError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"),
 
575
+                        flags);
 
576
+        return -1;
 
577
+    }
 
578
+
 
579
     for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
 
580
         if (priv->opened[i] && drivers[i]->domainGetMaxVcpus) {
 
581
             ret = drivers[i]->domainGetMaxVcpus (dom);
 
582
@@ -1140,6 +1159,13 @@ xenUnifiedDomainGetMaxVcpus (virDomainPtr dom)
 
583
     return -1;
 
584
 }
 
585
 
 
586
+static int
 
587
+xenUnifiedDomainGetMaxVcpus (virDomainPtr dom)
 
588
+{
 
589
+    return xenUnifiedDomainGetVcpusFlags(dom, (VIR_DOMAIN_VCPU_LIVE |
 
590
+                                               VIR_DOMAIN_VCPU_MAXIMUM));
 
591
+}
 
592
+
 
593
 static char *
 
594
 xenUnifiedDomainDumpXML (virDomainPtr dom, int flags)
 
595
 {
 
596
@@ -1951,8 +1977,8 @@ static virDriver xenUnifiedDriver = {
 
597
     xenUnifiedDomainRestore, /* domainRestore */
 
598
     xenUnifiedDomainCoreDump, /* domainCoreDump */
 
599
     xenUnifiedDomainSetVcpus, /* domainSetVcpus */
 
600
-    NULL, /* domainSetVcpusFlags */
 
601
-    NULL, /* domainGetVcpusFlags */
 
602
+    xenUnifiedDomainSetVcpusFlags, /* domainSetVcpusFlags */
 
603
+    xenUnifiedDomainGetVcpusFlags, /* domainGetVcpusFlags */
 
604
     xenUnifiedDomainPinVcpu, /* domainPinVcpu */
 
605
     xenUnifiedDomainGetVcpus, /* domainGetVcpus */
 
606
     xenUnifiedDomainGetMaxVcpus, /* domainGetMaxVcpus */
 
607
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
 
608
index 753169c..7d4ab8d 100644
 
609
--- a/src/xenapi/xenapi_driver.c
 
610
+++ b/src/xenapi/xenapi_driver.c
 
611
@@ -40,6 +40,11 @@
 
612
 #include "xenapi_driver_private.h"
 
613
 #include "xenapi_utils.h"
 
614
 
 
615
+#define VIR_FROM_THIS VIR_FROM_XENAPI
 
616
+
 
617
+#define xenapiError(code, ...)                                    \
 
618
+        virReportErrorHelper(NULL, VIR_FROM_THIS, code, __FILE__, \
 
619
+                             __FUNCTION__, __LINE__, __VA_ARGS__)
 
620
 
 
621
 /*
 
622
  * getCapsObject
 
623
@@ -987,19 +992,26 @@ xenapiDomainGetInfo (virDomainPtr dom, virDomainInfoPtr info)
 
624
 
 
625
 
 
626
 /*
 
627
- * xenapiDomainSetVcpus
 
628
+ * xenapiDomainSetVcpusFlags
 
629
  *
 
630
  * Sets the VCPUs on the domain
 
631
  * Return 0 on success or -1 in case of error
 
632
  */
 
633
 static int
 
634
-xenapiDomainSetVcpus (virDomainPtr dom, unsigned int nvcpus)
 
635
+xenapiDomainSetVcpusFlags (virDomainPtr dom, unsigned int nvcpus,
 
636
+                           unsigned int flags)
 
637
 {
 
638
-
 
639
     /* vm.set_vcpus_max */
 
640
     xen_vm vm;
 
641
     xen_vm_set *vms;
 
642
     xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
 
643
+
 
644
+    if (flags != VIR_DOMAIN_VCPU_LIVE) {
 
645
+        xenapiError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"),
 
646
+                    flags);
 
647
+        return -1;
 
648
+    }
 
649
+
 
650
     if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) {
 
651
         if (vms->size != 1) {
 
652
             xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
 
653
@@ -1019,6 +1031,18 @@ xenapiDomainSetVcpus (virDomainPtr dom, unsigned int nvcpus)
 
654
 }
 
655
 
 
656
 /*
 
657
+ * xenapiDomainSetVcpus
 
658
+ *
 
659
+ * Sets the VCPUs on the domain
 
660
+ * Return 0 on success or -1 in case of error
 
661
+ */
 
662
+static int
 
663
+xenapiDomainSetVcpus (virDomainPtr dom, unsigned int nvcpus)
 
664
+{
 
665
+    return xenapiDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_VCPU_LIVE);
 
666
+}
 
667
+
 
668
+/*
 
669
  * xenapiDomainPinVcpu
 
670
  *
 
671
  * Dynamically change the real CPUs which can be allocated to a virtual CPU
 
672
@@ -1140,19 +1164,26 @@ xenapiDomainGetVcpus (virDomainPtr dom,
 
673
 }
 
674
 
 
675
 /*
 
676
- * xenapiDomainGetMaxVcpus
 
677
+ * xenapiDomainGetVcpusFlags
 
678
  *
 
679
  *
 
680
- * Returns maximum number of Vcpus on success or -1 in case of error
 
681
+ * Returns Vcpus count on success or -1 in case of error
 
682
  */
 
683
 static int
 
684
-xenapiDomainGetMaxVcpus (virDomainPtr dom)
 
685
+xenapiDomainGetVcpusFlags (virDomainPtr dom, unsigned int flags)
 
686
 {
 
687
     xen_vm vm;
 
688
     xen_vm_set *vms;
 
689
     int64_t maxvcpu = 0;
 
690
     enum xen_vm_power_state state;
 
691
     xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
 
692
+
 
693
+    if (flags != (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) {
 
694
+        xenapiError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"),
 
695
+                    flags);
 
696
+        return -1;
 
697
+    }
 
698
+
 
699
     if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) {
 
700
         if (vms->size != 1) {
 
701
             xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
 
702
@@ -1176,6 +1207,19 @@ xenapiDomainGetMaxVcpus (virDomainPtr dom)
 
703
 }
 
704
 
 
705
 /*
 
706
+ * xenapiDomainGetMaxVcpus
 
707
+ *
 
708
+ *
 
709
+ * Returns maximum number of Vcpus on success or -1 in case of error
 
710
+ */
 
711
+static int
 
712
+xenapiDomainGetMaxVcpus (virDomainPtr dom)
 
713
+{
 
714
+    return xenapiDomainGetVcpusFlags(dom, (VIR_DOMAIN_VCPU_LIVE |
 
715
+                                           VIR_DOMAIN_VCPU_MAXIMUM));
 
716
+}
 
717
+
 
718
+/*
 
719
  * xenapiDomainDumpXML
 
720
  *
 
721
  *
 
722
@@ -1754,8 +1798,8 @@ static virDriver xenapiDriver = {
 
723
     NULL, /* domainRestore */
 
724
     NULL, /* domainCoreDump */
 
725
     xenapiDomainSetVcpus, /* domainSetVcpus */
 
726
-    NULL, /* domainSetVcpusFlags */
 
727
-    NULL, /* domainGetVcpusFlags */
 
728
+    xenapiDomainSetVcpusFlags, /* domainSetVcpusFlags */
 
729
+    xenapiDomainGetVcpusFlags, /* domainGetVcpusFlags */
 
730
     xenapiDomainPinVcpu, /* domainPinVcpu */
 
731
     xenapiDomainGetVcpus, /* domainGetVcpus */
 
732
     xenapiDomainGetMaxVcpus, /* domainGetMaxVcpus */
 
733
-- 
 
734
1.7.2.3
 
735