-
Notifications
You must be signed in to change notification settings - Fork 12
/
libvirt-0.10.2-mingw.patch
461 lines (414 loc) · 16 KB
/
libvirt-0.10.2-mingw.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
--- a/python/Makefile.am 2010-05-26 22:09:50 +0000
+++ b/python/Makefile.am 2010-09-10 20:26:24 +0000
@@ -41,9 +41,9 @@
libvirtmod_la_CFLAGS = $(WARN_PYTHON_CFLAGS)
libvirtmod_la_LDFLAGS = -module -avoid-version -shared -L$(top_builddir)/src/.libs \
- $(CYGWIN_EXTRA_LDFLAGS)
+ $(CYGWIN_EXTRA_LDFLAGS) $(MINGW_EXTRA_LDFLAGS) -L/python/libs
libvirtmod_la_LIBADD = $(mylibs) \
- $(CYGWIN_EXTRA_LIBADD) $(CYGWIN_EXTRA_PYTHON_LIBADD)
+ $(CYGWIN_EXTRA_LIBADD) $(CYGWIN_EXTRA_PYTHON_LIBADD) -lpython26
GENERATE = generator.py
API_DESC = $(top_srcdir)/docs/libvirt-api.xml $(srcdir)/libvirt-override-api.xml
diff -ur a/python/Makefile.in b/python/Makefile.in
--- a/python/Makefile.in 2010-09-07 17:46:28 +0000
+++ b/python/Makefile.in 2010-09-10 21:04:52 +0000
@@ -1118,10 +1118,10 @@
# need extra flags here
@WITH_PYTHON_TRUE@libvirtmod_la_CFLAGS = $(WARN_PYTHON_CFLAGS)
@WITH_PYTHON_TRUE@libvirtmod_la_LDFLAGS = -module -avoid-version -shared -L$(top_builddir)/src/.libs \
-@WITH_PYTHON_TRUE@ $(CYGWIN_EXTRA_LDFLAGS)
+@WITH_PYTHON_TRUE@ $(CYGWIN_EXTRA_LDFLAGS) $(MINGW_EXTRA_LDFLAGS) -L/python/libs
@WITH_PYTHON_TRUE@libvirtmod_la_LIBADD = $(mylibs) \
-@WITH_PYTHON_TRUE@ $(CYGWIN_EXTRA_LIBADD) $(CYGWIN_EXTRA_PYTHON_LIBADD)
+@WITH_PYTHON_TRUE@ $(CYGWIN_EXTRA_LIBADD) $(CYGWIN_EXTRA_PYTHON_LIBADD) -lpython26
@WITH_PYTHON_TRUE@GENERATE = generator.py
@WITH_PYTHON_TRUE@API_DESC = $(top_srcdir)/docs/libvirt-api.xml $(srcdir)/libvirt-override-api.xml
Make the remote driver use TLS certificates from %APPDATA%\libvirt\pki\ instead of /etc/pki/
--- a/src/remote/remote_driver.c 2010-11-11 17:25:02 +0000
+++ b/src/remote/remote_driver.c 2010-11-20 12:04:52 +0000
@@ -276,6 +276,70 @@
static int initialize_gnutls(void);
static gnutls_session_t negotiate_gnutls_on_connection (virConnectPtr conn, struct private_data *priv, int no_verify);
+#ifdef WIN32
+
+static char *remoteWin32CertPaths[5];
+
+static int
+remoteInitCertPaths(void)
+{
+ const char *appdata = getenv("APPDATA");
+
+ if (appdata == NULL || *appdata == '\0') {
+ appdata = "C:";
+
+ VIR_WARN("APPDATA not set, falling back to '%s'", appdata);
+ }
+
+ if (virAsprintf(&remoteWin32CertPaths[0],
+ "%s\\libvirt\\pki\\CA\\cacert.pem", appdata) < 0 ||
+ virAsprintf(&remoteWin32CertPaths[1],
+ "%s\\libvirt\\pki\\libvirt\\private\\clientkey.pem", appdata) < 0 ||
+ virAsprintf(&remoteWin32CertPaths[2],
+ "%s\\libvirt\\pki\\libvirt\\clientcert.pem", appdata) < 0 ||
+ virAsprintf(&remoteWin32CertPaths[3],
+ "%s\\libvirt\\pki\\libvirt\\private\\serverkey.pem", appdata) < 0 ||
+ virAsprintf(&remoteWin32CertPaths[4],
+ "%s\\libvirt\\pki\\libvirt\\servercert.pem", appdata) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+
+ return 0;
+}
+
+static const char *
+remoteCACertPath(void)
+{
+ return remoteWin32CertPaths[0];
+}
+
+static const char *
+remoteClientKeyPath(void)
+{
+ return remoteWin32CertPaths[1];
+}
+
+static const char *
+remoteClientCertPath(void)
+{
+ return remoteWin32CertPaths[2];
+}
+
+static const char *
+remoteServerKeyPath(void)
+{
+ return remoteWin32CertPaths[3];
+}
+
+static const char *
+remoteServerCertPath(void)
+{
+ return remoteWin32CertPaths[4];
+}
+
+#endif /* WIN32 */
+
#ifdef WITH_LIBVIRTD
static int
remoteStartup(int privileged ATTRIBUTE_UNUSED)
@@ -4881,6 +4971,10 @@
{
remoteDriver = &remote_driver;
+#ifdef WIN32
+ if (remoteInitCertPaths()) return -1;
+#endif
+
if (virRegisterDriver (&remote_driver) == -1) return -1;
if (virRegisterNetworkDriver (&network_driver) == -1) return -1;
if (virRegisterInterfaceDriver (&interface_driver) == -1) return -1;
--- a/src/remote/remote_driver.h 2010-11-17 17:25:02 +0000
+++ b/src/remote/remote_driver.h 2010-11-18 08:24:54 +0000
@@ -41,12 +41,19 @@
# define LIBVIRTD_CONFIGURATION_FILE SYSCONFDIR "/libvirtd.conf"
/* Defaults for PKI directory. */
-# define LIBVIRT_PKI_DIR SYSCONFDIR "/pki"
-# define LIBVIRT_CACERT LIBVIRT_PKI_DIR "/CA/cacert.pem"
-# define LIBVIRT_CLIENTKEY LIBVIRT_PKI_DIR "/libvirt/private/clientkey.pem"
-# define LIBVIRT_CLIENTCERT LIBVIRT_PKI_DIR "/libvirt/clientcert.pem"
-# define LIBVIRT_SERVERKEY LIBVIRT_PKI_DIR "/libvirt/private/serverkey.pem"
-# define LIBVIRT_SERVERCERT LIBVIRT_PKI_DIR "/libvirt/servercert.pem"
-
+# ifndef WIN32
+# define LIBVIRT_PKI_DIR SYSCONFDIR "/pki"
+# define LIBVIRT_CACERT LIBVIRT_PKI_DIR "/CA/cacert.pem"
+# define LIBVIRT_CLIENTKEY LIBVIRT_PKI_DIR "/libvirt/private/clientkey.pem"
+# define LIBVIRT_CLIENTCERT LIBVIRT_PKI_DIR "/libvirt/clientcert.pem"
+# define LIBVIRT_SERVERKEY LIBVIRT_PKI_DIR "/libvirt/private/serverkey.pem"
+# define LIBVIRT_SERVERCERT LIBVIRT_PKI_DIR "/libvirt/servercert.pem"
+# else
+# define LIBVIRT_CACERT remoteCACertPath()
+# define LIBVIRT_CLIENTKEY remoteClientKeyPath()
+# define LIBVIRT_CLIENTCERT remoteClientCertPath()
+# define LIBVIRT_SERVERKEY remoteServerKeyPath()
+# define LIBVIRT_SERVERCERT remoteServerCertPath()
+# endif
#endif /* __VIR_REMOTE_INTERNAL_H__ */
--- a/src/util/virauth.c
+++ b/src/util/virauth.c
@@ -100,7 +100,7 @@ no_memory:
goto cleanup;
}
-
+/*
static int
virAuthGetCredential(virConnectPtr conn,
const char *servicename,
@@ -144,25 +144,25 @@ cleanup:
virAuthConfigFree(config);
VIR_FREE(path);
return ret;
-}
+}*/
char *
-virAuthGetUsername(virConnectPtr conn,
+virAuthGetUsername(virConnectPtr conn ATTRIBUTE_UNUSED,
virConnectAuthPtr auth,
- const char *servicename,
+ const char *servicename ATTRIBUTE_UNUSED,
const char *defaultUsername,
const char *hostname)
{
unsigned int ncred;
virConnectCredential cred;
char *prompt;
- char *ret = NULL;
+ /*char *ret = NULL;
if (virAuthGetCredential(conn, servicename, "username", &ret) < 0)
return NULL;
if (ret != NULL)
- return ret;
+ return ret;*/
memset(&cred, 0, sizeof(virConnectCredential));
@@ -204,21 +204,21 @@ virAuthGetUsername(virConnectPtr conn,
char *
-virAuthGetPassword(virConnectPtr conn,
+virAuthGetPassword(virConnectPtr conn ATTRIBUTE_UNUSED,
virConnectAuthPtr auth,
- const char *servicename,
+ const char *servicename ATTRIBUTE_UNUSED,
const char *username,
const char *hostname)
{
unsigned int ncred;
virConnectCredential cred;
char *prompt;
- char *ret = NULL;
+ /*char *ret = NULL;
if (virAuthGetCredential(conn, servicename, "password", &ret) < 0)
return NULL;
if (ret != NULL)
- return ret;
+ return ret;*/
memset(&cred, 0, sizeof(virConnectCredential));
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -5008,13 +5008,15 @@ esxListAllDomains(virConnectPtr conn,
{
int ret = -1;
esxPrivate *priv = conn->privateData;
+ bool needIdentity;
+ bool needPowerState;
virDomainPtr dom;
virDomainPtr *doms = NULL;
size_t ndoms = 0;
+ esxVI_String *propertyNameList = NULL;
esxVI_ObjectContent *virtualMachineList = NULL;
esxVI_ObjectContent *virtualMachine = NULL;
- esxVI_String *propertyNameList = NULL;
- esxVI_AutoStartDefaults *autostart_defaults = NULL;
+ esxVI_AutoStartDefaults *autoStartDefaults = NULL;
esxVI_VirtualMachinePowerState powerState;
esxVI_AutoStartPowerInfo *powerInfoList = NULL;
esxVI_AutoStartPowerInfo *powerInfo = NULL;
@@ -5023,7 +5025,6 @@ esxListAllDomains(virConnectPtr conn,
int id;
unsigned char uuid[VIR_UUID_BUFLEN];
int count = 0;
- int snapshotCount;
bool autostart;
int state;
@@ -5033,7 +5034,7 @@ esxListAllDomains(virConnectPtr conn,
* - persistence: all esx machines are persistent
* - managed save: esx doesn't support managed save
*/
- if ((MATCH(VIR_CONNECT_LIST_DOMAINS_TRANSIENT) &&
+ if ((MATCH(VIR_CONNECT_LIST_DOMAINS_TRANSIENT) &&
!MATCH(VIR_CONNECT_LIST_DOMAINS_PERSISTENT)) ||
(MATCH(VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE) &&
!MATCH(VIR_CONNECT_LIST_DOMAINS_NO_MANAGEDSAVE))) {
@@ -5045,23 +5046,49 @@ esxListAllDomains(virConnectPtr conn,
goto cleanup;
}
- if (esxVI_EnsureSession(priv->primary) < 0)
+ if (esxVI_EnsureSession(priv->primary) < 0)
return -1;
/* check system default autostart value */
if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_AUTOSTART)) {
if (esxVI_LookupAutoStartDefaults(priv->primary,
- &autostart_defaults) < 0)
+ &autoStartDefaults) < 0) {
+ goto cleanup;
+ }
+
+ if (autoStartDefaults->enabled == esxVI_Boolean_True) {
+ if (esxVI_LookupAutoStartPowerInfoList(priv->primary,
+ &powerInfoList) < 0) {
+ goto cleanup;
+ }
+ }
+ }
+
+ needIdentity = MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_SNAPSHOT) ||
+ domains != NULL;
+
+ if (needIdentity) {
+ /* Request required data for esxVI_GetVirtualMachineIdentity */
+ if (esxVI_String_AppendValueListToList(&propertyNameList,
+ "configStatus\0"
+ "name\0"
+ "config.uuid\0") < 0) {
goto cleanup;
+ }
+ }
+
+ needPowerState = MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE) ||
+ MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE) ||
+ domains != NULL;
- if (esxVI_LookupAutoStartPowerInfoList(priv->primary,
- &powerInfoList) < 0)
+ if (needPowerState) {
+ if (esxVI_String_AppendValueToList(&propertyNameList,
+ "runtime.powerState") < 0) {
goto cleanup;
+ }
}
- if (esxVI_String_AppendValueToList(&propertyNameList,
- "runtime.powerState") < 0 ||
- esxVI_LookupVirtualMachineList(priv->primary, propertyNameList,
+ if (esxVI_LookupVirtualMachineList(priv->primary, propertyNameList,
&virtualMachineList) < 0)
goto cleanup;
@@ -5073,12 +5100,21 @@ esxListAllDomains(virConnectPtr conn,
for (virtualMachine = virtualMachineList; virtualMachine != NULL;
virtualMachine = virtualMachine->_next) {
+ if (needIdentity) {
+ VIR_FREE(name);
- VIR_FREE(name);
+ if (esxVI_GetVirtualMachineIdentity(virtualMachine, &id,
+ &name, uuid) < 0) {
+ goto cleanup;
+ }
+ }
- if (esxVI_GetVirtualMachineIdentity(virtualMachine, &id, &name, uuid) < 0 ||
- esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0)
- goto cleanup;
+ if (needPowerState) {
+ if (esxVI_GetVirtualMachinePowerState(virtualMachine,
+ &powerState) < 0) {
+ goto cleanup;
+ }
+ }
/* filter by active state */
if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE) &&
@@ -5090,23 +5126,17 @@ esxListAllDomains(virConnectPtr conn,
/* filter by snapshot existence */
if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_SNAPSHOT)) {
+ esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotTreeList);
+
if (esxVI_LookupRootSnapshotTreeList(priv->primary, uuid,
&rootSnapshotTreeList) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Couldn't retrieve snapshot list for "
- "domain '%s'"), name);
goto cleanup;
}
- snapshotCount = esxVI_GetNumberOfSnapshotTrees(rootSnapshotTreeList,
- true, false);
-
- esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotTreeList);
-
if (!((MATCH(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT) &&
- snapshotCount > 0) ||
+ rootSnapshotTreeList != NULL) ||
(MATCH(VIR_CONNECT_LIST_DOMAINS_NO_SNAPSHOT) &&
- snapshotCount == 0)))
+ rootSnapshotTreeList == NULL)))
continue;
}
@@ -5114,19 +5144,18 @@ esxListAllDomains(virConnectPtr conn,
if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_AUTOSTART)) {
autostart = false;
- for (powerInfo = powerInfoList; powerInfo != NULL;
- powerInfo = powerInfo->_next) {
- if (STREQ(powerInfo->key->value, virtualMachine->obj->value)) {
- if (STRCASEEQ(powerInfo->startAction, "powerOn"))
- autostart = true;
+ if (autoStartDefaults->enabled == esxVI_Boolean_True) {
+ for (powerInfo = powerInfoList; powerInfo != NULL;
+ powerInfo = powerInfo->_next) {
+ if (STREQ(powerInfo->key->value, virtualMachine->obj->value)) {
+ if (STRCASEEQ(powerInfo->startAction, "powerOn"))
+ autostart = true;
- break;
+ break;
+ }
}
}
- autostart = autostart &&
- autostart_defaults->enabled == esxVI_Boolean_True;
-
if (!((MATCH(VIR_CONNECT_LIST_DOMAINS_AUTOSTART) &&
autostart) ||
(MATCH(VIR_CONNECT_LIST_DOMAINS_NO_AUTOSTART) &&
@@ -5137,6 +5166,7 @@ esxListAllDomains(virConnectPtr conn,
/* filter by domain state */
if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE)) {
state = esxVI_VirtualMachinePowerState_ConvertToLibvirt(powerState);
+
if (!((MATCH(VIR_CONNECT_LIST_DOMAINS_RUNNING) &&
state == VIR_DOMAIN_RUNNING) ||
(MATCH(VIR_CONNECT_LIST_DOMAINS_PAUSED) &&
@@ -5156,17 +5186,18 @@ esxListAllDomains(virConnectPtr conn,
continue;
}
- if (!(dom = virGetDomain(conn, name, uuid)))
+ if (VIR_RESIZE_N(doms, ndoms, count, 2) < 0)
goto no_memory;
+ if (!(dom = virGetDomain(conn, name, uuid)))
+ goto cleanup;
+
/* Only running/suspended virtual machines have an ID != -1 */
if (powerState != esxVI_VirtualMachinePowerState_PoweredOff)
dom->id = id;
else
dom->id = -1;
- if (VIR_EXPAND_N(doms, ndoms, 1) < 0)
- goto no_memory;
doms[count++] = dom;
}
@@ -5178,14 +5209,19 @@ esxListAllDomains(virConnectPtr conn,
cleanup:
if (doms) {
for (id = 0; id < count; id++) {
- if (doms[id])
- virDomainFree(doms[id]);
+ virDomainFree(doms[id]);
}
+
+ VIR_FREE(doms);
}
- VIR_FREE(doms);
+
VIR_FREE(name);
+ esxVI_AutoStartDefaults_Free(&autoStartDefaults);
+ esxVI_AutoStartPowerInfo_Free(&powerInfoList);
esxVI_String_Free(&propertyNameList);
esxVI_ObjectContent_Free(&virtualMachineList);
+ esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotTreeList);
+
return ret;
no_memory:
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -275,7 +275,11 @@ int virSetInherit(int fd, bool inherit) {
int virSetInherit(int fd ATTRIBUTE_UNUSED, bool inherit ATTRIBUTE_UNUSED)
{
- return -1;
+ /* FIXME: Currently creating child processes is not supported on
+ * Win32, so there is no point in failing calls that are only relevant
+ * when creating child processes. So just pretend that we changed the
+ * inheritance property of the given fd as requested. */
+ return 0;
}
#endif /* WIN32 */