[libvirt] [PATCH v4 RESEND 4/4] Using threadpool API to manage qemud worker

2010-12-01 Thread Hu Tao
---
 daemon/libvirtd.c |  172 +
 daemon/libvirtd.h |4 +
 2 files changed, 33 insertions(+), 143 deletions(-)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 791b3dc..dbd050a 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -67,6 +67,7 @@
 #include "stream.h"
 #include "hooks.h"
 #include "virtaudit.h"
+#include "threadpool.h"
 #ifdef HAVE_AVAHI
 # include "mdns.h"
 #endif
@@ -248,7 +249,6 @@ static void sig_handler(int sig, siginfo_t * siginfo,
 
 static void qemudDispatchClientEvent(int watch, int fd, int events, void 
*opaque);
 static void qemudDispatchServerEvent(int watch, int fd, int events, void 
*opaque);
-static int qemudStartWorker(struct qemud_server *server, struct qemud_worker 
*worker);
 
 void
 qemudClientMessageQueuePush(struct qemud_client_message **queue,
@@ -1383,6 +1383,7 @@ static int qemudDispatchServer(struct qemud_server 
*server, struct qemud_socket
 client->auth = sock->auth;
 client->addr = addr;
 client->addrstr = addrstr;
+client->server = server;
 addrstr = NULL;
 
 for (i = 0 ; i < VIR_DOMAIN_EVENT_ID_LAST ; i++) {
@@ -1458,19 +1459,6 @@ static int qemudDispatchServer(struct qemud_server 
*server, struct qemud_socket
 
 server->clients[server->nclients++] = client;
 
-if (server->nclients > server->nactiveworkers &&
-server->nactiveworkers < server->nworkers) {
-for (i = 0 ; i < server->nworkers ; i++) {
-if (!server->workers[i].hasThread) {
-if (qemudStartWorker(server, &server->workers[i]) < 0)
-return -1;
-server->nactiveworkers++;
-break;
-}
-}
-}
-
-
 return 0;
 
 error:
@@ -1534,100 +1522,27 @@ void qemudDispatchClientFailure(struct qemud_client 
*client) {
 VIR_FREE(client->addrstr);
 }
 
-
-/* Caller must hold server lock */
-static struct qemud_client *qemudPendingJob(struct qemud_server *server)
+static void qemudWorker(void *data, void *opaque ATTRIBUTE_UNUSED)
 {
-int i;
-for (i = 0 ; i < server->nclients ; i++) {
-virMutexLock(&server->clients[i]->lock);
-if (server->clients[i]->dx) {
-/* Delibrately don't unlock client - caller wants the lock */
-return server->clients[i];
-}
-virMutexUnlock(&server->clients[i]->lock);
-}
-return NULL;
-}
+struct qemud_client *client = data;
+struct qemud_client_message *msg;
 
-static void *qemudWorker(void *data)
-{
-struct qemud_worker *worker = data;
-struct qemud_server *server = worker->server;
+virMutexLock(&client->lock);
 
-while (1) {
-struct qemud_client *client = NULL;
-struct qemud_client_message *msg;
+/* Remove our message from dispatch queue while we use it */
+msg = qemudClientMessageQueueServe(&client->dx);
 
-virMutexLock(&server->lock);
-while ((client = qemudPendingJob(server)) == NULL) {
-if (worker->quitRequest ||
-virCondWait(&server->job, &server->lock) < 0) {
-virMutexUnlock(&server->lock);
-return NULL;
-}
-}
-if (worker->quitRequest) {
-virMutexUnlock(&client->lock);
-virMutexUnlock(&server->lock);
-return NULL;
-}
-worker->processingCall = 1;
-virMutexUnlock(&server->lock);
-
-/* We own a locked client now... */
-client->refs++;
-
-/* Remove our message from dispatch queue while we use it */
-msg = qemudClientMessageQueueServe(&client->dx);
-
-/* This function drops the lock during dispatch,
- * and re-acquires it before returning */
-if (remoteDispatchClientRequest (server, client, msg) < 0) {
-VIR_FREE(msg);
-qemudDispatchClientFailure(client);
-client->refs--;
-virMutexUnlock(&client->lock);
-continue;
-}
-
-client->refs--;
-virMutexUnlock(&client->lock);
-
-virMutexLock(&server->lock);
-worker->processingCall = 0;
-virMutexUnlock(&server->lock);
-}
-}
-
-static int qemudStartWorker(struct qemud_server *server,
-struct qemud_worker *worker) {
-pthread_attr_t attr;
-pthread_attr_init(&attr);
-/* We want to join workers, so don't detach them */
-/*pthread_attr_setdetachstate(&attr, 1);*/
-
-if (worker->hasThread)
-return -1;
-
-worker->server = server;
-worker->hasThread = 1;
-worker->quitRequest = 0;
-worker->processingCall = 0;
-
-if (pthread_create(&worker->thread,
-   &attr,
-   qemudWorker,
-   worker) != 0) {
-worker->hasThread = 0;
-worker->server = NULL;
-return -1;
+/* This function drops the lock during dispatch,
+ * and re-acquires it before returnin

[libvirt] [PATCH v4 RESEND 3/4] Add a watchdog action `dump'

2010-12-01 Thread Hu Tao
`dump' watchdog action lets libvirtd to dump the guest when receives a
watchdog event (which probably means a guest crash)

Currently only qemu is supported.
---
 src/conf/domain_conf.c |1 +
 src/conf/domain_conf.h |1 +
 src/qemu/qemu.conf |5 +++
 src/qemu/qemu_conf.c   |   16 -
 src/qemu/qemu_conf.h   |5 +++
 src/qemu/qemu_driver.c |   95 
 6 files changed, 122 insertions(+), 1 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3f14cee..a6cb444 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -245,6 +245,7 @@ VIR_ENUM_IMPL(virDomainWatchdogAction, 
VIR_DOMAIN_WATCHDOG_ACTION_LAST,
   "shutdown",
   "poweroff",
   "pause",
+  "dump",
   "none")
 
 VIR_ENUM_IMPL(virDomainVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 899b19f..7f50b79 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -462,6 +462,7 @@ enum virDomainWatchdogAction {
 VIR_DOMAIN_WATCHDOG_ACTION_SHUTDOWN,
 VIR_DOMAIN_WATCHDOG_ACTION_POWEROFF,
 VIR_DOMAIN_WATCHDOG_ACTION_PAUSE,
+VIR_DOMAIN_WATCHDOG_ACTION_DUMP,
 VIR_DOMAIN_WATCHDOG_ACTION_NONE,
 
 VIR_DOMAIN_WATCHDOG_ACTION_LAST
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index f4f965e..ba41f80 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -191,6 +191,11 @@
 # save_image_format = "raw"
 # dump_image_format = "raw"
 
+# When a domain is configured to be auto-dumped when libvirtd receives a
+# watchdog event from qemu guest, libvirtd will save dump files in directory
+# specified by auto_dump_path. Default value is /var/lib/libvirt/qemu/dump
+#
+# auto_dump_path = "/var/lib/libvirt/qemu/dump"
 
 # If provided by the host and a hugetlbfs mount point is configured,
 # a guest may request huge page backing.  When this mount point is
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 7cd0603..187e206 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -386,6 +386,17 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
 }
 }
 
+p = virConfGetValue (conf, "auto_dump_path");
+CHECK_TYPE ("auto_dump_path", VIR_CONF_STRING);
+if (p && p->str) {
+VIR_FREE(driver->autoDumpPath);
+if (!(driver->autoDumpPath = strdup(p->str))) {
+virReportOOMError();
+virConfFree(conf);
+return -1;
+}
+}
+
  p = virConfGetValue (conf, "hugetlbfs_mount");
  CHECK_TYPE ("hugetlbfs_mount", VIR_CONF_STRING);
  if (p && p->str) {
@@ -5374,7 +5385,10 @@ int qemudBuildCommandLine(virConnectPtr conn,
 }
 ADD_ARG(optstr);
 
-const char *action = 
virDomainWatchdogActionTypeToString(watchdog->action);
+int act = watchdog->action;
+if (act == VIR_DOMAIN_WATCHDOG_ACTION_DUMP)
+act = VIR_DOMAIN_WATCHDOG_ACTION_PAUSE;
+const char *action = virDomainWatchdogActionTypeToString(act);
 if (!action) {
 qemuReportError(VIR_ERR_INTERNAL_ERROR,
 "%s", _("invalid watchdog action"));
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index aba64d6..9bcae88 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -41,6 +41,7 @@
 # include "driver.h"
 # include "bitmap.h"
 # include "macvtap.h"
+# include "threadpool.h"
 
 # define qemudDebug(fmt, ...) do {} while(0)
 
@@ -107,6 +108,8 @@ enum qemud_cmd_flags {
 struct qemud_driver {
 virMutex lock;
 
+virThreadPoolPtr workerPool;
+
 int privileged;
 
 uid_t user;
@@ -174,6 +177,8 @@ struct qemud_driver {
 char *saveImageFormat;
 char *dumpImageFormat;
 
+char *autoDumpPath;
+
 pciDeviceList *activePciHostdevs;
 
 virBitmapPtr reservedVNCPorts;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e534195..bd25d90 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -85,6 +85,7 @@
 #include "files.h"
 #include "fdstream.h"
 #include "configmake.h"
+#include "threadpool.h"
 
 #define VIR_FROM_THIS VIR_FROM_QEMU
 
@@ -137,6 +138,14 @@ struct _qemuDomainObjPrivate {
 int persistentAddrs;
 };
 
+struct watchdogEvent
+{
+virDomainObjPtr vm;
+int action;
+};
+
+static void processWatchdogEvent(void *data, void *opaque);
+
 static int qemudShutdown(void);
 
 static void qemuDriverLock(struct qemud_driver *driver)
@@ -1204,6 +1213,17 @@ qemuHandleDomainWatchdog(qemuMonitorPtr mon 
ATTRIBUTE_UNUSED,
 if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
 VIR_WARN("Unable to save status on vm %s after IO error", 
vm->def->name);
 }
+
+if (vm->def->watchdog->action == VIR_DOMAIN_WATCHDOG_ACTION_DUMP) {
+struct watchdogEvent *wdEvent;
+if (VIR_ALLOC(wdEvent) == 0) {
+wdEvent->action = VIR_DOMAIN_WATCHDOG_ACTION_DUMP;
+

[libvirt] [PATCH v4 RESEND 2/4] Add a new function doCoreDump

2010-12-01 Thread Hu Tao
This patch prepares for the next patch.
---
 src/qemu/qemu_driver.c |  132 +++-
 1 files changed, 74 insertions(+), 58 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1a7c1ad..e534195 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6063,6 +6063,78 @@ cleanup:
 return ret;
 }
 
+static int doCoreDump(struct qemud_driver *driver,
+  virDomainObjPtr vm,
+  const char *path,
+  enum qemud_save_formats compress)
+{
+int fd = -1;
+int ret = -1;
+qemuDomainObjPrivatePtr priv;
+
+priv = vm->privateData;
+
+/* Create an empty file with appropriate ownership.  */
+if ((fd = open(path, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR)) < 0) {
+qemuReportError(VIR_ERR_OPERATION_FAILED,
+_("failed to create '%s'"), path);
+goto cleanup;
+}
+
+if (VIR_CLOSE(fd) < 0) {
+virReportSystemError(errno,
+ _("unable to save file %s"),
+ path);
+goto cleanup;
+}
+
+if (driver->securityDriver &&
+driver->securityDriver->domainSetSavedStateLabel &&
+
driver->securityDriver->domainSetSavedStateLabel(driver->securityDriver,
+ vm, path) == -1)
+goto cleanup;
+
+qemuDomainObjEnterMonitorWithDriver(driver, vm);
+if (compress == QEMUD_SAVE_FORMAT_RAW) {
+const char *args[] = {
+"cat",
+NULL,
+};
+ret = qemuMonitorMigrateToFile(priv->mon,
+   QEMU_MONITOR_MIGRATE_BACKGROUND,
+   args, path, 0);
+} else {
+const char *prog = qemudSaveCompressionTypeToString(compress);
+const char *args[] = {
+prog,
+"-c",
+NULL,
+};
+ret = qemuMonitorMigrateToFile(priv->mon,
+   QEMU_MONITOR_MIGRATE_BACKGROUND,
+   args, path, 0);
+}
+qemuDomainObjExitMonitorWithDriver(driver, vm);
+if (ret < 0)
+goto cleanup;
+
+ret = qemuDomainWaitForMigrationComplete(driver, vm);
+
+if (ret < 0)
+goto cleanup;
+
+if (driver->securityDriver &&
+driver->securityDriver->domainRestoreSavedStateLabel &&
+
driver->securityDriver->domainRestoreSavedStateLabel(driver->securityDriver,
+ vm, path) == -1)
+goto cleanup;
+
+cleanup:
+if (ret != 0)
+unlink(path);
+return ret;
+}
+
 static enum qemud_save_formats
 getCompressionType(struct qemud_driver *driver)
 {
@@ -6097,13 +6169,10 @@ static int qemudDomainCoreDump(virDomainPtr dom,
 struct qemud_driver *driver = dom->conn->privateData;
 virDomainObjPtr vm;
 int resume = 0, paused = 0;
-int ret = -1, fd = -1;
+int ret = -1;
 virDomainEventPtr event = NULL;
-enum qemud_save_formats compress;
 qemuDomainObjPrivatePtr priv;
 
-compress = getCompressionType(driver);
-
 qemuDriverLock(driver);
 vm = virDomainFindByUUID(&driver->domains, dom->uuid);
 
@@ -6125,26 +6194,6 @@ static int qemudDomainCoreDump(virDomainPtr dom,
 goto endjob;
 }
 
-/* Create an empty file with appropriate ownership.  */
-if ((fd = open(path, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR)) < 0) {
-qemuReportError(VIR_ERR_OPERATION_FAILED,
-_("failed to create '%s'"), path);
-goto endjob;
-}
-
-if (VIR_CLOSE(fd) < 0) {
-virReportSystemError(errno,
- _("unable to save file %s"),
- path);
-goto endjob;
-}
-
-if (driver->securityDriver &&
-driver->securityDriver->domainSetSavedStateLabel &&
-
driver->securityDriver->domainSetSavedStateLabel(driver->securityDriver,
- vm, path) == -1)
-goto endjob;
-
 /* Migrate will always stop the VM, so the resume condition is
independent of whether the stop command is issued.  */
 resume = (vm->state == VIR_DOMAIN_RUNNING);
@@ -6168,43 +6217,12 @@ static int qemudDomainCoreDump(virDomainPtr dom,
 }
 }
 
-qemuDomainObjEnterMonitorWithDriver(driver, vm);
-if (compress == QEMUD_SAVE_FORMAT_RAW) {
-const char *args[] = {
-"cat",
-NULL,
-};
-ret = qemuMonitorMigrateToFile(priv->mon,
-   QEMU_MONITOR_MIGRATE_BACKGROUND,
-   args, path, 0);
-} else {
-const char *prog = qemudSaveCompressionTypeToString(compress);
-const char *args[] = {
-prog,
-"-c",
-NULL,
-};
-ret

[libvirt] [PATCH v4 RESEND 1/4] threadpool impl

2010-12-01 Thread Hu Tao
* src/util/threadpool.c, src/util/threadpool.h: Thread pool
  implementation
* src/Makefile.am: Build thread pool
* src/libvirt_private.syms: Export public functions
---
 cfg.mk   |1 +
 src/Makefile.am  |1 +
 src/libvirt_private.syms |6 +
 src/util/threadpool.c|  235 ++
 src/util/threadpool.h|   49 ++
 5 files changed, 292 insertions(+), 0 deletions(-)
 create mode 100644 src/util/threadpool.c
 create mode 100644 src/util/threadpool.h

diff --git a/cfg.mk b/cfg.mk
index 5576ecb..e4ee763 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -127,6 +127,7 @@ useless_free_options =  \
   --name=virStoragePoolObjFree \
   --name=virStoragePoolSourceFree  \
   --name=virStorageVolDefFree  \
+  --name=virThreadPoolFree \
   --name=xmlFree   \
   --name=xmlXPathFreeContext   \
   --name=xmlXPathFreeObject
diff --git a/src/Makefile.am b/src/Makefile.am
index a9a1986..d71c644 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -73,6 +73,7 @@ UTIL_SOURCES =
\
util/threads.c util/threads.h   \
util/threads-pthread.h  \
util/threads-win32.h\
+   util/threadpool.c util/threadpool.h \
util/uuid.c util/uuid.h \
util/util.c util/util.h \
util/xml.c util/xml.h   \
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index f251c94..70c68cb 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -861,3 +861,9 @@ virXPathStringLimit;
 virXPathULong;
 virXPathULongHex;
 virXPathULongLong;
+
+
+# threadpool.h
+virThreadPoolNew;
+virThreadPoolFree;
+virThreadPoolSendJob;
diff --git a/src/util/threadpool.c b/src/util/threadpool.c
new file mode 100644
index 000..a5f24c2
--- /dev/null
+++ b/src/util/threadpool.c
@@ -0,0 +1,235 @@
+/*
+ * threadpool.c: a generic thread pool implementation
+ *
+ * Copyright (C) 2010 Hu Tao
+ * Copyright (C) 2010 Daniel P. Berrange
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Authors:
+ * Hu Tao 
+ * Daniel P. Berrange 
+ */
+
+#include 
+
+#include "threadpool.h"
+#include "memory.h"
+#include "threads.h"
+#include "virterror_internal.h"
+#include "ignore-value.h"
+
+#define VIR_FROM_THIS VIR_FROM_NONE
+
+typedef struct _virThreadPoolJob virThreadPoolJob;
+typedef virThreadPoolJob *virThreadPoolJobPtr;
+
+struct _virThreadPoolJob {
+virThreadPoolJobPtr next;
+
+void *data;
+};
+
+typedef struct _virThreadPoolJobList virThreadPoolJobList;
+typedef virThreadPoolJobList *virThreadPoolJobListPtr;
+
+struct _virThreadPoolJobList {
+virThreadPoolJobPtr head;
+virThreadPoolJobPtr *tail;
+};
+
+
+struct _virThreadPool {
+bool quit;
+
+virThreadPoolJobFunc jobFunc;
+void *jobOpaque;
+virThreadPoolJobList jobList;
+
+virMutex mutex;
+virCond cond;
+virCond quit_cond;
+
+size_t maxWorkers;
+size_t freeWorkers;
+size_t nWorkers;
+virThreadPtr workers;
+};
+
+static void virThreadPoolWorker(void *opaque)
+{
+virThreadPoolPtr pool = opaque;
+
+virMutexLock(&pool->mutex);
+
+while (1) {
+while (!pool->quit &&
+   !pool->jobList.head) {
+pool->freeWorkers++;
+if (virCondWait(&pool->cond, &pool->mutex) < 0) {
+pool->freeWorkers--;
+goto out;
+}
+pool->freeWorkers--;
+}
+
+if (pool->quit)
+break;
+
+virThreadPoolJobPtr job = pool->jobList.head;
+pool->jobList.head = pool->jobList.head->next;
+job->next = NULL;
+if (pool->jobList.tail == &job->next)
+pool->jobList.tail = &pool->jobList.head;
+
+virMutexUnlock(&pool->mutex);
+(pool->jobFunc)(job->data, pool->jobOpaque);
+VIR_FREE(job);
+virMutexLock(&pool->mutex);
+}
+
+out:
+pool->nWorkers--;
+if (pool->nWorkers == 0)
+ 

[libvirt] [PATCH v4 RESEND 0/4] Support of auto-dump on watchdog event in libvirtd

2010-12-01 Thread Hu Tao
This patch series adds a new watchdog action `dump' which lets libvirtd
can do auto-dump when receiving a watchdog event from qemu guest.

In order to make the function work, there must be a watchdog device
added to guest, and guest must have a watchdog daemon running, for
example, /etc/init.d/watchdog start or auto-started on boot.

Changes:

v4:

- updated threadpool to follow libvirt naming style, use appropriate
  internals APIs, and hide the struct definitions from the header
  (by Daniel)
- fix an error that qemuDomainObjBeginJobWithDriver() get lost in
  qemuDomainCoreDump()
- use thread pool in libvirtd (qemud worker)

v3:

- let default auto-dump dir be /var/lib/libvirt/qemu/dump

Hu Tao (4):
  threadpool impl
  Add a new function doCoreDump
  Add a watchdog action `dump'
  Using threadpool API to manage qemud worker

 cfg.mk   |1 +
 daemon/libvirtd.c|  172 ++
 daemon/libvirtd.h|4 +
 src/Makefile.am  |1 +
 src/conf/domain_conf.c   |1 +
 src/conf/domain_conf.h   |1 +
 src/libvirt_private.syms |6 +
 src/qemu/qemu.conf   |5 +
 src/qemu/qemu_conf.c |   16 +++-
 src/qemu/qemu_conf.h |5 +
 src/qemu/qemu_driver.c   |  227 +---
 src/util/threadpool.c|  235 ++
 src/util/threadpool.h|   49 ++
 13 files changed, 521 insertions(+), 202 deletions(-)
 create mode 100644 src/util/threadpool.c
 create mode 100644 src/util/threadpool.h

-- 
1.7.3


-- 
Thanks,
Hu Tao

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


Re: [libvirt] [PATCH] virsh: move two commands from domain group to storage pool group

2010-12-01 Thread Justin Clift
On 02/12/2010, at 11:25 AM, Osier Yang wrote:
> * tools/virsh.c (find-storage-pool-sources-as and find-storage-pool-sources
> should't be in command group "Domain Management", move them to group
> "Storage Pool".
> ---
> tools/virsh.c |8 
> 1 files changed, 4 insertions(+), 4 deletions(-)

ACK.

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


[libvirt] GNU awk vs BSD awk?

2010-12-01 Thread Justin Clift
Hi Eric,

One of the OSX Homebrew guys, CC'd, has asked (casually) whether our dependency 
on GNU awk is very deeply ingrained, or if we could be convinced to allow usage 
of other make's instead (ie BSD).

Figured I'd ask you directly, as you'd probably best know whether it's an easy 
thing to address or not?

Any idea?

Regards and best wishes,

Justin Clift


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


[libvirt] Create VMWare ESXi domain via virsh error(error: this function is not supported by the connection driver: virDomainCreateXML)

2010-12-01 Thread mop amg
Hi, Dear.
I have two questions ask for help:
my virt-manager and libvirt version is :
linux-vaan:~ # rpm -q libvirt
libvirt-0.8.5-1.2.i586
linux-vaan:~ # uname -a
Linux linux-vaan 2.6.34-12-desktop #1 SMP PREEMPT 2010-06-29 02:39:08 +0200
i686 i386 GNU/Linux
linux-vaan:~ # rpm -q virt-manager
virt-manager-0.8.5-3.1.i586
linux-vaan:~ # cat /etc/SuSE-release
openSUSE 11.3 (i586)
VERSION = 11.3

virsh # version
Compiled against library: libvir 0.8.5
Using library: libvir 0.8.5
Using API: ESX 0.8.5
Running hypervisor: ESX 4.1.0


*question 1 : *
When I try to create a vmware esxi domain from virsh like this :
   create --file /work/dom1.x
 there is a  error message :
   error: Failed to create domain from /work/dom1.xml
   error: this function is not supported by the connection driver:
virDomainCreateXML
it seems dosen't support create esxi domain, but the
http://libvirt.org/hvsupport.html show that is supported after ≥ 0.7.0

or create via virt-install

  linux-vaan:~ # virt-install --connect=esx://
r...@192.168.8.162/?no_verify=1 -n rhel5 -r 512 --vcpus=1  --nodisks
bridge=vmk0 --network bridge=vmk0 --pxe

  Enter root's password for 192.168.8.162:



  Starting install...

  ERRORthis function is not supported by the connection driver:
virDomainCreateXML


how to  fix it ?

*dom1.xml*

  dom1
  524288
  524288
  1
  
hvm
  
  
  destroy
  restart
  destroy
  

  
  
  



  
  

  

*question 2:*
vol-clone failed

virsh # vol-clone --pool datastore1 rhel5/rhel5.vmdk rhel5/rhel5_2.vmdk

error: Failed to clone vol from rhel5/rhel5.vmdk

error: this function is not supported by the connection driver:
virStorageVolCreateXMLFrom


thanks for help!


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

Re: [libvirt] [PATCH] virsh: Remove using phy as default disk driver in cmdAttachDisk

2010-12-01 Thread Eric Blake
On 12/01/2010 06:19 PM, Osier Yang wrote:
> * tools/virsh.c (virsh shouldn't use 'phy' as the disk driver if
> user doesn't specify "--driver", it causes bugs, as not all of
> hypervisor driver supports 'phy', and actually hypervisor should
> known the correct default disk driver and subdriver, so remove it)
> ---
>  tools/virsh.c |   11 ---
>  1 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/virsh.c b/tools/virsh.c
> index 6a9aba2..5b5c5ee 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -8668,11 +8668,16 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
>  virBufferVSprintf(&buf, " device='%s'", type);
>  virBufferAddLit(&buf, ">\n");
> 
> -virBufferVSprintf(&buf, "   -  (driver) ? driver : "phy");
> +if (driver || subdriver)
> +virBufferVSprintf(&buf, "   +
> +if (driver)
> +virBufferVSprintf(&buf, " name='%s'", driver);

This generates two spaces instead of 1.  I've cleanup up the driver line.

ACK with that nit fixed, and pushed.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v4 0/7] Support of auto-dump on watchdog event in libvirtd

2010-12-01 Thread Hu Tao
On Thu, Dec 02, 2010 at 09:04:22AM +0800, Hu Tao wrote:
> This patch series adds a new watchdog action `dump' which lets libvirtd
> can do auto-dump when receiving a watchdog event from qemu guest.
> 
> In order to make the function work, there must be a watchdog device
> added to guest, and guest must have a watchdog daemon running, for
> example, /etc/init.d/watchdog start or auto-started on boot.
> 
> Changes:
> 
> v4:
> 
> - getCompressionType returns type of enum qemud_save_formats rather
>   than int
> - use virThread api in thread pool
> - fix an error that qemuDomainObjBeginJobWithDriver() get lost in
>   qemuDomainCoreDump()
and:
  - use thread pool in libvirtd (qemud worker)

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


Re: [libvirt] [PATCH v4 0/7] Support of auto-dump on watchdog event in libvirtd

2010-12-01 Thread Hu Tao
On Wed, Dec 01, 2010 at 06:44:02PM -0700, Eric Blake wrote:
> On 12/01/2010 06:04 PM, Hu Tao wrote:
> > This patch series adds a new watchdog action `dump' which lets libvirtd
> > can do auto-dump when receiving a watchdog event from qemu guest.
> > 
> > In order to make the function work, there must be a watchdog device
> > added to guest, and guest must have a watchdog daemon running, for
> > example, /etc/init.d/watchdog start or auto-started on boot.
> > 
> > Changes:
> > 
> > v4:
> > 
> > - getCompressionType returns type of enum qemud_save_formats rather
> >   than int
> > - use virThread api in thread pool
> > - fix an error that qemuDomainObjBeginJobWithDriver() get lost in
> >   qemuDomainCoreDump()
> 
> You'll want to update to the latest libvirt.git, and rebase this series
> on top of that. 

Oops! I forgot to do a pull&rebase again.

> In particular, you don't need to commit any po/*.po
> file changes ('git checkout po' is the easiest way to undo those changes
> if running 'make' caused them to be regenerated), and patches 3 and 7
> have already been incorporated upstream, so they are no longer needed in
> your series.

While I was sending patch 2 I saw those POes and realized stg messed my
tree up and redid patch 2 before sending it.(But patch 0 was already
sent so those POes were listed there)

> 
> > Hu Tao (7):
> >   bug: local var referenced in another thread
> >   Add a threadpool implementation
> >   Fall back to QEMUD_SAVE_FORMAT_RAW if compression method fails.
> >   Add a new function doCoreDump
> >   Add a watchdog action `dump'
> >   Using threadpool API to manage qemud worker
> >   Add me to AUTHORS to make `make syntax-check' happy
> > 
> >  AUTHORS|1 +
> >  cfg.mk |3 +-
> >  daemon/libvirtd.c  |  168 +
> >  daemon/libvirtd.h  |4 +
> >  po/af.po   |   14 ++--
> >  po/am.po   |   14 ++--
> 
> Hmm; this diffstat appears to include uncommitted changes on your HEAD,
> since none of the 7 commits actually included po changes.
> 
> -- 
> Eric Blake   ebl...@redhat.com+1-801-349-2682
> Libvirt virtualization library http://libvirt.org
> 


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


Re: [libvirt] [PATCH 1/8] Thread pool impl

2010-12-01 Thread Hu Tao
On Wed, Dec 01, 2010 at 05:26:27PM +, Daniel P. Berrange wrote:
> From: Hu Tao 
> 
> * src/util/threadpool.c, src/util/threadpool.h: Thread pool
>   implementation
> * src/Makefile.am: Build thread pool
> ---
>  src/Makefile.am   |1 +
>  src/util/threadpool.c |  178 
> +
>  src/util/threadpool.h |   23 ++
>  3 files changed, 202 insertions(+), 0 deletions(-)
>  create mode 100644 src/util/threadpool.c
>  create mode 100644 src/util/threadpool.h
> 
> diff --git a/src/Makefile.am b/src/Makefile.am
> index a9a1986..d71c644 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -73,6 +73,7 @@ UTIL_SOURCES =  
> \
>   util/threads.c util/threads.h   \
>   util/threads-pthread.h  \
>   util/threads-win32.h\
> + util/threadpool.c util/threadpool.h \
>   util/uuid.c util/uuid.h \
>   util/util.c util/util.h \
>   util/xml.c util/xml.h   \
> diff --git a/src/util/threadpool.c b/src/util/threadpool.c
> new file mode 100644
> index 000..cf998bf
> --- /dev/null
> +++ b/src/util/threadpool.c
> @@ -0,0 +1,178 @@
> +
> +#include 
> +
> +#include "threadpool.h"
> +#include "memory.h"
> +#include "threads.h"
> +#include "virterror_internal.h"
> +
> +#define VIR_FROM_THIS VIR_FROM_NONE
> +
> +typedef struct _virThreadPoolJob virThreadPoolJob;
> +typedef virThreadPoolJob *virThreadPoolJobPtr;
> +
> +struct _virThreadPoolJob {
> +virThreadPoolJobPtr next;
> +
> +void *data;
> +};
> +
> +struct _virThreadPool {
> +int quit;
> +
> +virThreadPoolJobFunc jobFunc;
> +void *jobOpaque;
> +virThreadPoolJobPtr jobList;
> +
> +virMutex mutex;
> +virCond cond;
> +virCond quit_cond;
> +
> +size_t maxWorkers;
> +size_t freeWorkers;
> +size_t nWorkers;
> +virThreadPtr workers;
> +};
> +
> +static void virThreadPoolWorker(void *opaque)
> +{
> +virThreadPoolPtr pool = opaque;
> +
> +virMutexLock(&pool->mutex);
> +
> +while (1) {
> +while (!pool->quit &&
> +   !pool->jobList) {
> +pool->freeWorkers++;
> +if (virCondWait(&pool->cond, &pool->mutex) < 0) {
> +pool->freeWorkers--;
> +break;
> +}
> +pool->freeWorkers--;
> +}
> +
> +if (pool->quit)
> +break;
> +
> +virThreadPoolJobPtr job = pool->jobList;
> +pool->jobList = pool->jobList->next;
> +job->next = NULL;
> +
> +virMutexUnlock(&pool->mutex);
> +(pool->jobFunc)(job->data, pool->jobOpaque);

This could race if jobFunc does something with jobOpaque unless jobFunc
is aware of this and provides a lock to protect jobOpaque.

> +VIR_FREE(job);
> +virMutexLock(&pool->mutex);
> +}
> +
> +pool->nWorkers--;
> +if (pool->nWorkers == 0)
> +virCondSignal(&pool->quit_cond);
> +virMutexUnlock(&pool->mutex);
> +}
> +
> +virThreadPoolPtr virThreadPoolNew(size_t minWorkers,
> +  size_t maxWorkers,
> +  virThreadPoolJobFunc func,
> +  void *opaque)
> +{
> +virThreadPoolPtr pool;
> +int i;
> +
> +if (VIR_ALLOC(pool) < 0) {
> +virReportOOMError();
> +return NULL;
> +}
> +
> +pool->jobFunc = func;
> +pool->jobOpaque = opaque;
> +
> +if (virMutexInit(&pool->mutex) < 0)
> +goto error;
> +if (virCondInit(&pool->cond) < 0)
> +goto error;
> +if (virCondInit(&pool->quit_cond) < 0)
> +goto error;
> +
> +if (VIR_ALLOC_N(pool->workers, minWorkers) < 0)
> +goto error;
> +
> +pool->maxWorkers = maxWorkers;
> +for (i = 0; i < minWorkers; i++) {
> +if (virThreadCreate(&pool->workers[i],
> +true,
> +virThreadPoolWorker,
> +pool) < 0)
> +goto error;
> +pool->nWorkers++;
> +}

There will be more than maxWorkers threads created if
minWorkers > maxWorkers

> +
> +return pool;
> +
> +error:
> +virThreadPoolFree(pool);
> +return NULL;
> +}
> +
> +void virThreadPoolFree(virThreadPoolPtr pool)
> +{
> +virMutexLock(&pool->mutex);
> +pool->quit = 1;
> +if (pool->nWorkers > 0) {
> +virCondBroadcast(&pool->cond);
> +if (virCondWait(&pool->quit_cond, &pool->mutex) < 0)
> +{}
> +}
> +VIR_FREE(pool->workers);
> +virMutexUnlock(&pool->mutex);
> +VIR_FREE(pool);
> +}
> +
> +int virThreadPoolSendJob(virThreadPoolPtr pool,
> + void *jobData)
> +{
> +virThreadPoolJobPtr job;
> +virThreadPoolJobPtr tmp;
> +
> +virMutexLock(&

Re: [libvirt] [PATCH v4 0/7] Support of auto-dump on watchdog event in libvirtd

2010-12-01 Thread Eric Blake
On 12/01/2010 06:04 PM, Hu Tao wrote:
> This patch series adds a new watchdog action `dump' which lets libvirtd
> can do auto-dump when receiving a watchdog event from qemu guest.
> 
> In order to make the function work, there must be a watchdog device
> added to guest, and guest must have a watchdog daemon running, for
> example, /etc/init.d/watchdog start or auto-started on boot.
> 
> Changes:
> 
> v4:
> 
> - getCompressionType returns type of enum qemud_save_formats rather
>   than int
> - use virThread api in thread pool
> - fix an error that qemuDomainObjBeginJobWithDriver() get lost in
>   qemuDomainCoreDump()

You'll want to update to the latest libvirt.git, and rebase this series
on top of that.  In particular, you don't need to commit any po/*.po
file changes ('git checkout po' is the easiest way to undo those changes
if running 'make' caused them to be regenerated), and patches 3 and 7
have already been incorporated upstream, so they are no longer needed in
your series.

> Hu Tao (7):
>   bug: local var referenced in another thread
>   Add a threadpool implementation
>   Fall back to QEMUD_SAVE_FORMAT_RAW if compression method fails.
>   Add a new function doCoreDump
>   Add a watchdog action `dump'
>   Using threadpool API to manage qemud worker
>   Add me to AUTHORS to make `make syntax-check' happy
> 
>  AUTHORS|1 +
>  cfg.mk |3 +-
>  daemon/libvirtd.c  |  168 +
>  daemon/libvirtd.h  |4 +
>  po/af.po   |   14 ++--
>  po/am.po   |   14 ++--

Hmm; this diffstat appears to include uncommitted changes on your HEAD,
since none of the 7 commits actually included po changes.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v3 4/5] Add a watchdog action `dump'

2010-12-01 Thread Eric Blake
On 12/01/2010 05:50 PM, Hu Tao wrote:
> On Tue, Nov 30, 2010 at 03:21:36PM -0700, Eric Blake wrote:
> <...snip...>
>>>  
>>> -libvirt_qemu_la_SOURCES = libvirt-qemu.c
>>> +libvirt_qemu_la_SOURCES = libvirt-qemu.c util/threadpool.c
>>
>> Why is this change necessary?  Shouldn't libvirt_util.la already include
>> threadpool.c, and the qemu driver already be linking with libvirt_util.la?
> 
> Is this ok?
> 
> -libvirt_driver_qemu_la_LIBADD = $(NUMACTL_LIBS)
> +libvirt_driver_qemu_la_LIBADD = $(NUMACTL_LIBS) ../src/libvirt_util.la

Nope; rather...

> 
> Or link will fail:
> 
>   CCLD   libvirtd
> libvirtd-libvirtd.o: In function `qemudRunLoop':
> /mnt/data/kernel/libvirt/daemon/libvirtd.c:2229: undefined reference to 
> `virWorkerPoolNew'
> /mnt/data/kernel/libvirt/daemon/libvirtd.c:2287: undefined reference to 
> `virWorkerPoolFree'

That means you need to modify src/libvirt_private.syms to export the new
public interfaces from threadpool.h (it should be pretty easy to figure
out what edits to make, the tricky part is realizing you need to touch
that file in the first place).

>>> +if (virAsprintf(&qemu_driver->autoDumpPath, "%s/qemu/dump", base) 
>>> == -1)
>>> +goto out_of_memory;
>>
>> However, it does raise an issue.  Is qemu.conf only for privileged
>> users, or do we have to worry about allowing non-privileged users also
>> be able to pick up an alternate directory (especially since they can't
>> dump to /var/log/...)?
> 
> qemu.conf is only for privileged users, but non-privileged users who
> need to analyze dump files should ask admin to specify an auto-dump
> directory they have right to read.
> 
> Or do you have a better idea?

Is it better to dump a non-privileged log into ~/.libvirt/qemu/dump, so
that it's automatically user-accessible?  We already use ~/.libvirt for
other non-privileged files.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] virsh: Remove using phy as default disk driver in cmdAttachDisk

2010-12-01 Thread Osier Yang
* tools/virsh.c (virsh shouldn't use 'phy' as the disk driver if
user doesn't specify "--driver", it causes bugs, as not all of
hypervisor driver supports 'phy', and actually hypervisor should
known the correct default disk driver and subdriver, so remove it)
---
 tools/virsh.c |   11 ---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 6a9aba2..5b5c5ee 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -8668,11 +8668,16 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
 virBufferVSprintf(&buf, " device='%s'", type);
 virBufferAddLit(&buf, ">\n");

-virBufferVSprintf(&buf, "  \n");
+
+if (driver || subdriver)
+virBufferAddLit(&buf, "/>\n");

 virBufferVSprintf(&buf, "  \n",
   (isFile) ? "file" : "dev",
--
1.7.3.2

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


[libvirt] [PATCH v4 1/7] bug: local var referenced in another thread

2010-12-01 Thread Hu Tao
---
 src/util/threads-pthread.c |   13 +++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/util/threads-pthread.c b/src/util/threads-pthread.c
index 02070ae..54a3808 100644
--- a/src/util/threads-pthread.c
+++ b/src/util/threads-pthread.c
@@ -26,6 +26,7 @@
 # include 
 #endif
 
+#include "memory.h"
 
 /* Nothing special required for pthreads */
 int virThreadInitialize(void)
@@ -143,6 +144,7 @@ static void *virThreadHelper(void *data)
 {
 struct virThreadArgs *args = data;
 args->func(args->opaque);
+VIR_FREE(args);
 return NULL;
 }
 
@@ -151,13 +153,20 @@ int virThreadCreate(virThreadPtr thread,
 virThreadFunc func,
 void *opaque)
 {
-struct virThreadArgs args = { func, opaque };
+struct virThreadArgs *args;
 pthread_attr_t attr;
+
+if (VIR_ALLOC(args) < 0)
+return -1;
+
+args->func = func;
+args->opaque = opaque;
+
 pthread_attr_init(&attr);
 if (!joinable)
 pthread_attr_setdetachstate(&attr, 1);
 
-int ret = pthread_create(&thread->thread, &attr, virThreadHelper, &args);
+int ret = pthread_create(&thread->thread, &attr, virThreadHelper, args);
 if (ret != 0) {
 errno = ret;
 return -1;
-- 
1.7.3


-- 
Thanks,
Hu Tao

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


[libvirt] [PATCH v4 2/7] Add a threadpool implementation

2010-12-01 Thread Hu Tao
---
 src/Makefile.am   |1 +
 src/util/threadpool.c |  172 +
 src/util/threadpool.h |   62 ++
 3 files changed, 235 insertions(+), 0 deletions(-)
 create mode 100644 src/util/threadpool.c
 create mode 100644 src/util/threadpool.h

diff --git a/src/Makefile.am b/src/Makefile.am
index a9a1986..5febd76 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -76,6 +76,7 @@ UTIL_SOURCES =
\
util/uuid.c util/uuid.h \
util/util.c util/util.h \
util/xml.c util/xml.h   \
+   util/threadpool.c util/threadpool.h \
util/virtaudit.c util/virtaudit.h   \
util/virterror.c util/virterror_internal.h
 
diff --git a/src/util/threadpool.c b/src/util/threadpool.c
new file mode 100644
index 000..79f9fbb
--- /dev/null
+++ b/src/util/threadpool.c
@@ -0,0 +1,172 @@
+/*
+ * threadpool.c: a generic thread pool implementation
+ *
+ * Copyright (C) 2010 Hu Tao
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author:
+ * Hu Tao 
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include "threadpool.h"
+#include "memory.h"
+
+static void workerHandleJob(void *data)
+{
+virDataPtr localData = NULL;
+virWorkerPoolPtr pool = data;
+
+virMutexLock(&pool->mutex);
+
+while (1) {
+while (!pool->quit && !pool->dataList) {
+pool->nFreeWorker++;
+virCondSignal(&pool->worker_cond);
+if (virCondWait(&pool->cond, &pool->mutex) < 0) {
+pool->nFreeWorker--;
+goto out;
+}
+pool->nFreeWorker--;
+
+if (pool->nWorker > pool->nMaxWorker)
+goto out;
+}
+
+while ((localData = pool->dataList) != NULL) {
+pool->dataList = pool->dataList->next;
+localData->next = NULL;
+
+virMutexUnlock(&pool->mutex);
+
+(pool->func)(localData->data);
+VIR_FREE(localData);
+
+virMutexLock(&pool->mutex);
+}
+
+if (pool->quit)
+break;
+}
+
+out:
+pool->nWorker--;
+if (pool->nWorker == 0)
+virCondSignal(&pool->quit_cond);
+virMutexUnlock(&pool->mutex);
+}
+
+virWorkerPoolPtr virWorkerPoolNew(int nWorker, int maxWorker, virWorkerFunc 
func)
+{
+virWorkerPoolPtr pool;
+virThread thread;
+int i;
+
+if (nWorker < 0)
+return NULL;
+
+if (nWorker > maxWorker)
+return NULL;
+
+if (VIR_ALLOC(pool))
+return NULL;
+
+memset(pool, 0, sizeof(*pool));
+pool->func = func;
+if (virMutexInit(&pool->mutex) < 0)
+goto error;
+if (virCondInit(&pool->cond) < 0)
+goto error;
+if (virCondInit(&pool->worker_cond) < 0)
+goto error;
+if (virCondInit(&pool->quit_cond) < 0)
+goto error;
+
+for (i = 0; i < nWorker; i++) {
+if (virThreadCreate(&thread, true, workerHandleJob, pool) < 0) {
+pool->nWorker = i;
+goto error;
+}
+}
+
+pool->nFreeWorker = 0;
+pool->nWorker = nWorker;
+pool->nMaxWorker = maxWorker;
+
+return pool;
+error:
+virWorkerPoolFree(pool);
+return NULL;
+}
+
+void virWorkerPoolFree(virWorkerPoolPtr pool)
+{
+virMutexLock(&pool->mutex);
+pool->quit = true;
+if (pool->nWorker > 0) {
+virCondBroadcast(&pool->cond);
+virCondWait(&pool->quit_cond, &pool->mutex);
+}
+virMutexUnlock(&pool->mutex);
+VIR_FREE(pool);
+}
+
+int virWorkerPoolSendJob(virWorkerPoolPtr pool, void *data)
+{
+virThread thread;
+virDataPtr localData;
+
+if (VIR_ALLOC(localData))
+return -1;
+
+localData->data = data;
+
+virMutexLock(&pool->mutex);
+if (pool->quit) {
+virMutexUnlock(&pool->mutex);
+VIR_FREE(localData);
+return -1;
+}
+
+localData->next = pool->dataList;
+pool->dataList = localData;
+
+if (pool->nFreeWorker == 0 && pool->nWorker < pool->nMaxWorker) {
+if (virThreadCreate(&thread, true, workerHandleJob, pool) == 0)
+

[libvirt] [PATCH v4 4/7] Add a new function doCoreDump

2010-12-01 Thread Hu Tao
This patch prepares for the next patch.
---
 src/qemu/qemu_driver.c |  129 ++-
 1 files changed, 71 insertions(+), 58 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e6ba1a7..cc6891e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6057,6 +6057,75 @@ cleanup:
 return ret;
 }
 
+static int doCoreDump(struct qemud_driver *driver, virDomainObjPtr vm, const 
char *path, enum qemud_save_formats compress)
+{
+int fd = -1;
+int ret = -1;
+qemuDomainObjPrivatePtr priv;
+
+priv = vm->privateData;
+
+/* Create an empty file with appropriate ownership.  */
+if ((fd = open(path, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR)) < 0) {
+qemuReportError(VIR_ERR_OPERATION_FAILED,
+_("failed to create '%s'"), path);
+goto cleanup;
+}
+
+if (VIR_CLOSE(fd) < 0) {
+virReportSystemError(errno,
+ _("unable to save file %s"),
+ path);
+goto cleanup;
+}
+
+if (driver->securityDriver &&
+driver->securityDriver->domainSetSavedStateLabel &&
+
driver->securityDriver->domainSetSavedStateLabel(driver->securityDriver,
+ vm, path) == -1)
+goto cleanup;
+
+qemuDomainObjEnterMonitorWithDriver(driver, vm);
+if (compress == QEMUD_SAVE_FORMAT_RAW) {
+const char *args[] = {
+"cat",
+NULL,
+};
+ret = qemuMonitorMigrateToFile(priv->mon,
+   QEMU_MONITOR_MIGRATE_BACKGROUND,
+   args, path, 0);
+} else {
+const char *prog = qemudSaveCompressionTypeToString(compress);
+const char *args[] = {
+prog,
+"-c",
+NULL,
+};
+ret = qemuMonitorMigrateToFile(priv->mon,
+   QEMU_MONITOR_MIGRATE_BACKGROUND,
+   args, path, 0);
+}
+qemuDomainObjExitMonitorWithDriver(driver, vm);
+if (ret < 0)
+goto cleanup;
+
+ret = qemuDomainWaitForMigrationComplete(driver, vm);
+
+if (ret < 0)
+goto cleanup;
+
+if (driver->securityDriver &&
+driver->securityDriver->domainRestoreSavedStateLabel &&
+
driver->securityDriver->domainRestoreSavedStateLabel(driver->securityDriver,
+ vm, path) == -1)
+goto cleanup;
+
+cleanup:
+if (ret != 0)
+unlink(path);
+return ret;
+}
+
 static enum qemud_save_formats getCompressionType(struct qemud_driver *driver)
 {
 enum qemud_save_formats compress;
@@ -6090,13 +6159,10 @@ static int qemudDomainCoreDump(virDomainPtr dom,
 struct qemud_driver *driver = dom->conn->privateData;
 virDomainObjPtr vm;
 int resume = 0, paused = 0;
-int ret = -1, fd = -1;
+int ret = -1;
 virDomainEventPtr event = NULL;
-enum qemud_save_formats compress;
 qemuDomainObjPrivatePtr priv;
 
-compress = getCompressionType(driver);
-
 qemuDriverLock(driver);
 vm = virDomainFindByUUID(&driver->domains, dom->uuid);
 
@@ -6118,26 +6184,6 @@ static int qemudDomainCoreDump(virDomainPtr dom,
 goto endjob;
 }
 
-/* Create an empty file with appropriate ownership.  */
-if ((fd = open(path, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR)) < 0) {
-qemuReportError(VIR_ERR_OPERATION_FAILED,
-_("failed to create '%s'"), path);
-goto endjob;
-}
-
-if (VIR_CLOSE(fd) < 0) {
-virReportSystemError(errno,
- _("unable to save file %s"),
- path);
-goto endjob;
-}
-
-if (driver->securityDriver &&
-driver->securityDriver->domainSetSavedStateLabel &&
-
driver->securityDriver->domainSetSavedStateLabel(driver->securityDriver,
- vm, path) == -1)
-goto endjob;
-
 /* Migrate will always stop the VM, so the resume condition is
independent of whether the stop command is issued.  */
 resume = (vm->state == VIR_DOMAIN_RUNNING);
@@ -6161,43 +6207,12 @@ static int qemudDomainCoreDump(virDomainPtr dom,
 }
 }
 
-qemuDomainObjEnterMonitorWithDriver(driver, vm);
-if (compress == QEMUD_SAVE_FORMAT_RAW) {
-const char *args[] = {
-"cat",
-NULL,
-};
-ret = qemuMonitorMigrateToFile(priv->mon,
-   QEMU_MONITOR_MIGRATE_BACKGROUND,
-   args, path, 0);
-} else {
-const char *prog = qemudSaveCompressionTypeToString(compress);
-const char *args[] = {
-prog,
-"-c",
-NULL,
-};
-ret = qemuMonitorMigrateToFile(pri

[libvirt] [PATCH v4 5/7] Add a watchdog action `dump'

2010-12-01 Thread Hu Tao
`dump' watchdog action lets libvirtd to dump the guest when receives a
watchdog event (which probably means a guest crash)

Currently only qemu is supported.
---
 cfg.mk |3 +-
 src/Makefile.am|2 +-
 src/conf/domain_conf.c |1 +
 src/conf/domain_conf.h |1 +
 src/qemu/qemu.conf |5 ++
 src/qemu/qemu_conf.c   |   16 +++-
 src/qemu/qemu_conf.h   |5 ++
 src/qemu/qemu_driver.c |   99 
 src/util/threadpool.c  |3 +
 9 files changed, 132 insertions(+), 3 deletions(-)

diff --git a/cfg.mk b/cfg.mk
index 5576ecb..2eb0f77 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -129,7 +129,8 @@ useless_free_options =  \
   --name=virStorageVolDefFree  \
   --name=xmlFree   \
   --name=xmlXPathFreeContext   \
-  --name=xmlXPathFreeObject
+  --name=xmlXPathFreeObject\
+  --name=virWorkerPoolFree
 
 # The following template was generated by this command:
 # make ID && aid free|grep '^vi'|sed 's/ .*//;s/^/#   /'
diff --git a/src/Makefile.am b/src/Makefile.am
index 5febd76..83ccd7c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -646,7 +646,7 @@ endif
 libvirt_driver_qemu_la_CFLAGS = $(NUMACTL_CFLAGS) \
-...@top_srcdir@/src/conf $(AM_CFLAGS)
 libvirt_driver_qemu_la_LDFLAGS = $(AM_LDFLAGS)
-libvirt_driver_qemu_la_LIBADD = $(NUMACTL_LIBS)
+libvirt_driver_qemu_la_LIBADD = $(NUMACTL_LIBS) ../src/libvirt_util.la
 if WITH_DRIVER_MODULES
 libvirt_driver_qemu_la_LIBADD += ../gnulib/lib/libgnu.la
 libvirt_driver_qemu_la_LDFLAGS += -module -avoid-version
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3f14cee..a6cb444 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -245,6 +245,7 @@ VIR_ENUM_IMPL(virDomainWatchdogAction, 
VIR_DOMAIN_WATCHDOG_ACTION_LAST,
   "shutdown",
   "poweroff",
   "pause",
+  "dump",
   "none")
 
 VIR_ENUM_IMPL(virDomainVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 899b19f..7f50b79 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -462,6 +462,7 @@ enum virDomainWatchdogAction {
 VIR_DOMAIN_WATCHDOG_ACTION_SHUTDOWN,
 VIR_DOMAIN_WATCHDOG_ACTION_POWEROFF,
 VIR_DOMAIN_WATCHDOG_ACTION_PAUSE,
+VIR_DOMAIN_WATCHDOG_ACTION_DUMP,
 VIR_DOMAIN_WATCHDOG_ACTION_NONE,
 
 VIR_DOMAIN_WATCHDOG_ACTION_LAST
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index f4f965e..ba41f80 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -191,6 +191,11 @@
 # save_image_format = "raw"
 # dump_image_format = "raw"
 
+# When a domain is configured to be auto-dumped when libvirtd receives a
+# watchdog event from qemu guest, libvirtd will save dump files in directory
+# specified by auto_dump_path. Default value is /var/lib/libvirt/qemu/dump
+#
+# auto_dump_path = "/var/lib/libvirt/qemu/dump"
 
 # If provided by the host and a hugetlbfs mount point is configured,
 # a guest may request huge page backing.  When this mount point is
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index b0343c6..6296378 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -386,6 +386,17 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
 }
 }
 
+p = virConfGetValue (conf, "auto_dump_path");
+CHECK_TYPE ("auto_dump_path", VIR_CONF_STRING);
+if (p && p->str) {
+VIR_FREE(driver->autoDumpPath);
+if (!(driver->autoDumpPath = strdup(p->str))) {
+virReportOOMError();
+virConfFree(conf);
+return -1;
+}
+}
+
  p = virConfGetValue (conf, "hugetlbfs_mount");
  CHECK_TYPE ("hugetlbfs_mount", VIR_CONF_STRING);
  if (p && p->str) {
@@ -5373,7 +5384,10 @@ int qemudBuildCommandLine(virConnectPtr conn,
 }
 ADD_ARG(optstr);
 
-const char *action = 
virDomainWatchdogActionTypeToString(watchdog->action);
+int act = watchdog->action;
+if (act == VIR_DOMAIN_WATCHDOG_ACTION_DUMP)
+act = VIR_DOMAIN_WATCHDOG_ACTION_PAUSE;
+const char *action = virDomainWatchdogActionTypeToString(act);
 if (!action) {
 qemuReportError(VIR_ERR_INTERNAL_ERROR,
 "%s", _("invalid watchdog action"));
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index aba64d6..0956e7b 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -41,6 +41,7 @@
 # include "driver.h"
 # include "bitmap.h"
 # include "macvtap.h"
+# include "threadpool.h"
 
 # define qemudDebug(fmt, ...) do {} while(0)
 
@@ -107,6 +108,8 @@ enum qemud_cmd_flags {
 struct qemud_driver {
 virMutex lock;
 
+virWorkerPoolPtr workerPool;
+
 int privileged;
 
 uid_t user;
@@ -174,6 +177,8 @@ struct qemud_driver {
 char *saveImageFormat;
 char *dumpImageFormat;
 
+char

[libvirt] [PATCH v4 3/7] Fall back to QEMUD_SAVE_FORMAT_RAW if compression method fails.

2010-12-01 Thread Hu Tao
When dumping a domain, it's reasonable to save dump-file in raw format
if dump format is misconfigured or the corresponding compress program
is not available rather then fail dumping.
---
 src/qemu/qemu_driver.c |   41 +
 1 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 4877692..e6ba1a7 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6057,16 +6057,10 @@ cleanup:
 return ret;
 }
 
-static int qemudDomainCoreDump(virDomainPtr dom,
-   const char *path,
-   int flags ATTRIBUTE_UNUSED) {
-struct qemud_driver *driver = dom->conn->privateData;
-virDomainObjPtr vm;
-int resume = 0, paused = 0;
-int ret = -1, fd = -1;
-virDomainEventPtr event = NULL;
-int compress;
-qemuDomainObjPrivatePtr priv;
+static enum qemud_save_formats getCompressionType(struct qemud_driver *driver)
+{
+enum qemud_save_formats compress;
+
 /*
  * We reuse "save" flag for "dump" here. Then, we can support the same
  * format in "save" and "dump".
@@ -6074,19 +6068,34 @@ static int qemudDomainCoreDump(virDomainPtr dom,
 compress = QEMUD_SAVE_FORMAT_RAW;
 if (driver->dumpImageFormat) {
 compress = qemudSaveCompressionTypeFromString(driver->dumpImageFormat);
-if (compress < 0) {
-   qemuReportError(VIR_ERR_OPERATION_FAILED, "%s",
-   _("Invalid dump image format specified in "
- "configuration file"));
-   return -1;
+if ((signed)compress < 0) {
+qemuReportError(VIR_ERR_OPERATION_FAILED, "%s",
+_("Invalid dump image format specified in "
+  "configuration file"));
+return QEMUD_SAVE_FORMAT_RAW;
 }
 if (!qemudCompressProgramAvailable(compress)) {
 qemuReportError(VIR_ERR_OPERATION_FAILED,
 "%s", _("Compression program for dump image format 
"
 "in configuration file isn't available"));
-return -1;
+return QEMUD_SAVE_FORMAT_RAW;
 }
 }
+return compress;
+}
+
+static int qemudDomainCoreDump(virDomainPtr dom,
+   const char *path,
+   int flags ATTRIBUTE_UNUSED) {
+struct qemud_driver *driver = dom->conn->privateData;
+virDomainObjPtr vm;
+int resume = 0, paused = 0;
+int ret = -1, fd = -1;
+virDomainEventPtr event = NULL;
+enum qemud_save_formats compress;
+qemuDomainObjPrivatePtr priv;
+
+compress = getCompressionType(driver);
 
 qemuDriverLock(driver);
 vm = virDomainFindByUUID(&driver->domains, dom->uuid);
-- 
1.7.3


-- 
Thanks,
Hu Tao

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


[libvirt] [PATCH v4 7/7] Add me to AUTHORS to make `make syntax-check' happy

2010-12-01 Thread Hu Tao
---
 AUTHORS |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 16c755d..ca2414c 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -136,6 +136,7 @@ Patches have also been contributed by:
   Osier Yang   
   Kamezawa Hiroyuki
   Wen Congyang 
+  Hu Tao   
 
   [send patches to get your name here]
 
-- 
1.7.3


-- 
Thanks,
Hu Tao

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


[libvirt] [PATCH v4 0/7] Support of auto-dump on watchdog event in libvirtd

2010-12-01 Thread Hu Tao
This patch series adds a new watchdog action `dump' which lets libvirtd
can do auto-dump when receiving a watchdog event from qemu guest.

In order to make the function work, there must be a watchdog device
added to guest, and guest must have a watchdog daemon running, for
example, /etc/init.d/watchdog start or auto-started on boot.

Changes:

v4:

- getCompressionType returns type of enum qemud_save_formats rather
  than int
- use virThread api in thread pool
- fix an error that qemuDomainObjBeginJobWithDriver() get lost in
  qemuDomainCoreDump()

v3:

- let default auto-dump dir be /var/lib/libvirt/qemu/dump

Hu Tao (7):
  bug: local var referenced in another thread
  Add a threadpool implementation
  Fall back to QEMUD_SAVE_FORMAT_RAW if compression method fails.
  Add a new function doCoreDump
  Add a watchdog action `dump'
  Using threadpool API to manage qemud worker
  Add me to AUTHORS to make `make syntax-check' happy

 AUTHORS|1 +
 cfg.mk |3 +-
 daemon/libvirtd.c  |  168 +
 daemon/libvirtd.h  |4 +
 po/af.po   |   14 ++--
 po/am.po   |   14 ++--
 po/ar.po   |   14 ++--
 po/as.po   |   14 ++--
 po/be.po   |   14 ++--
 po/bg.po   |   18 ++--
 po/bn.po   |   14 ++--
 po/bn_IN.po|   18 ++--
 po/bs.po   |   14 ++--
 po/ca.po   |   42 
 po/cs.po   |   14 ++--
 po/cy.po   |   14 ++--
 po/da.po   |   14 ++--
 po/de.po   |   22 ++--
 po/el.po   |   22 ++--
 po/en_GB.po|   14 ++--
 po/es.po   |   54 +-
 po/et.po   |   14 ++--
 po/eu_ES.po|   14 ++--
 po/fa.po   |   14 ++--
 po/fi.po   |   14 ++--
 po/fr.po   |   94 
 po/gl.po   |   14 ++--
 po/gu.po   |   14 ++--
 po/he.po   |   14 ++--
 po/hi.po   |   14 ++--
 po/hr.po   |   18 ++--
 po/hu.po   |   14 ++--
 po/hy.po   |   14 ++--
 po/id.po   |   14 ++--
 po/is.po   |   14 ++--
 po/it.po   |   54 +-
 po/ja.po   |   18 ++--
 po/ka.po   |   14 ++--
 po/kn.po   |   14 ++--
 po/ko.po   |   14 ++--
 po/ku.po   |   14 ++--
 src/Makefile.am|3 +-
 src/conf/domain_conf.c |1 +
 src/conf/domain_conf.h |1 +
 src/qemu/qemu.conf |5 +
 src/qemu/qemu_conf.c   |   16 +++-
 src/qemu/qemu_conf.h   |5 +
 src/qemu/qemu_driver.c |  259 
 src/util/threadpool.c  |  175 ++
 src/util/threadpool.h  |   62 +++
 src/util/threads-pthread.c |   13 ++-
 51 files changed, 868 insertions(+), 586 deletions(-)
 create mode 100644 src/util/threadpool.c
 create mode 100644 src/util/threadpool.h

-- 
1.7.3


-- 
Thanks,
Hu Tao

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


[libvirt] [PATCH v4 6/7] Using threadpool API to manage qemud worker

2010-12-01 Thread Hu Tao
---
 daemon/libvirtd.c |  168 -
 daemon/libvirtd.h |4 +
 2 files changed, 29 insertions(+), 143 deletions(-)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index caf51bf..f4987a3 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -67,6 +67,7 @@
 #include "stream.h"
 #include "hooks.h"
 #include "virtaudit.h"
+#include "threadpool.h"
 #ifdef HAVE_AVAHI
 # include "mdns.h"
 #endif
@@ -248,7 +249,6 @@ static void sig_handler(int sig, siginfo_t * siginfo,
 
 static void qemudDispatchClientEvent(int watch, int fd, int events, void 
*opaque);
 static void qemudDispatchServerEvent(int watch, int fd, int events, void 
*opaque);
-static int qemudStartWorker(struct qemud_server *server, struct qemud_worker 
*worker);
 
 void
 qemudClientMessageQueuePush(struct qemud_client_message **queue,
@@ -1383,6 +1383,7 @@ static int qemudDispatchServer(struct qemud_server 
*server, struct qemud_socket
 client->auth = sock->auth;
 client->addr = addr;
 client->addrstr = addrstr;
+client->server = server;
 addrstr = NULL;
 
 for (i = 0 ; i < VIR_DOMAIN_EVENT_ID_LAST ; i++) {
@@ -1458,19 +1459,6 @@ static int qemudDispatchServer(struct qemud_server 
*server, struct qemud_socket
 
 server->clients[server->nclients++] = client;
 
-if (server->nclients > server->nactiveworkers &&
-server->nactiveworkers < server->nworkers) {
-for (i = 0 ; i < server->nworkers ; i++) {
-if (!server->workers[i].hasThread) {
-if (qemudStartWorker(server, &server->workers[i]) < 0)
-return -1;
-server->nactiveworkers++;
-break;
-}
-}
-}
-
-
 return 0;
 
 error:
@@ -1534,100 +1522,27 @@ void qemudDispatchClientFailure(struct qemud_client 
*client) {
 VIR_FREE(client->addrstr);
 }
 
-
-/* Caller must hold server lock */
-static struct qemud_client *qemudPendingJob(struct qemud_server *server)
+static void qemudWorker(void *data)
 {
-int i;
-for (i = 0 ; i < server->nclients ; i++) {
-virMutexLock(&server->clients[i]->lock);
-if (server->clients[i]->dx) {
-/* Delibrately don't unlock client - caller wants the lock */
-return server->clients[i];
-}
-virMutexUnlock(&server->clients[i]->lock);
-}
-return NULL;
-}
+struct qemud_client *client = data;
+struct qemud_client_message *msg;
 
-static void *qemudWorker(void *data)
-{
-struct qemud_worker *worker = data;
-struct qemud_server *server = worker->server;
+virMutexLock(&client->lock);
 
-while (1) {
-struct qemud_client *client = NULL;
-struct qemud_client_message *msg;
+/* Remove our message from dispatch queue while we use it */
+msg = qemudClientMessageQueueServe(&client->dx);
 
-virMutexLock(&server->lock);
-while ((client = qemudPendingJob(server)) == NULL) {
-if (worker->quitRequest ||
-virCondWait(&server->job, &server->lock) < 0) {
-virMutexUnlock(&server->lock);
-return NULL;
-}
-}
-if (worker->quitRequest) {
-virMutexUnlock(&client->lock);
-virMutexUnlock(&server->lock);
-return NULL;
-}
-worker->processingCall = 1;
-virMutexUnlock(&server->lock);
-
-/* We own a locked client now... */
-client->refs++;
-
-/* Remove our message from dispatch queue while we use it */
-msg = qemudClientMessageQueueServe(&client->dx);
-
-/* This function drops the lock during dispatch,
- * and re-acquires it before returning */
-if (remoteDispatchClientRequest (server, client, msg) < 0) {
-VIR_FREE(msg);
-qemudDispatchClientFailure(client);
-client->refs--;
-virMutexUnlock(&client->lock);
-continue;
-}
-
-client->refs--;
-virMutexUnlock(&client->lock);
-
-virMutexLock(&server->lock);
-worker->processingCall = 0;
-virMutexUnlock(&server->lock);
-}
-}
-
-static int qemudStartWorker(struct qemud_server *server,
-struct qemud_worker *worker) {
-pthread_attr_t attr;
-pthread_attr_init(&attr);
-/* We want to join workers, so don't detach them */
-/*pthread_attr_setdetachstate(&attr, 1);*/
-
-if (worker->hasThread)
-return -1;
-
-worker->server = server;
-worker->hasThread = 1;
-worker->quitRequest = 0;
-worker->processingCall = 0;
-
-if (pthread_create(&worker->thread,
-   &attr,
-   qemudWorker,
-   worker) != 0) {
-worker->hasThread = 0;
-worker->server = NULL;
-return -1;
+/* This function drops the lock during dispatch,
+ * and re-acquires it before returning */
+if (remoteDispatchCli

Re: [libvirt] [PATCH 2/2] smbios: support system family

2010-12-01 Thread Eric Blake
On 12/01/2010 05:12 PM, Eric Blake wrote:
> * docs/schemas/domain.rng (sysinfo-system-name): Also allow
> family.

Unfortunately,  and  were never documented in
docs/formatdomain.html.in; we'll have to add that before we can add
string to that documentation.

> +++ b/tests/qemuxml2argvdata/qemuxml2argv-smbios.xml
> @@ -15,6 +15,8 @@
>0.8.2-3.fc14
>32dfcb37-5af1-552b-357c-be8c3aa38310
>c7a5fdbd-edaf-9455-926a-d65c16db1809
> +  1234567890
> +  Red Hat

Don't we typically use '' rather than "" for attribute values?  We
should probably fix that to be consistent as well.

Another problem I just noticed - I can't roundtrip from  back to the full-blown  on my
laptop, because my laptop has the following dmidecode entries:

Handle 0x, DMI type 0, 24 bytes
Vendor: LENOVO
Version: 6FET82WW (3.12 )
Release Date: 11/26/2009
BIOS Revision: 3.18
Handle 0x0100, DMI type 1, 27 bytes
Manufacturer: LENOVO
Product Name: 2241B36
Version: ThinkPad T500
Serial Number: R89055N
UUID: E321ED02-FAC8-9337-B0E7-C3B32580E899
SKU Number: Not Specified
Family: Red Hat Enterprise Linux

but the schema only allows:

  

  [a-zA-Z0-9/\-_\. ]+

  

which rejects my Version string in block 0.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] virsh: move two commands from domain group to storage pool group

2010-12-01 Thread Osier Yang
* tools/virsh.c (find-storage-pool-sources-as and find-storage-pool-sources
should't be in command group "Domain Management", move them to group
"Storage Pool".
---
 tools/virsh.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 6a9aba2..8d84394 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -9957,10 +9957,6 @@ static const vshCmdDef domManagementCmds[] = {
 {"dumpxml", cmdDumpXML, opts_dumpxml, info_dumpxml},
 {"echo", cmdEcho, opts_echo, info_echo},
 {"edit", cmdEdit, opts_edit, info_edit},
-{"find-storage-pool-sources-as", cmdPoolDiscoverSourcesAs,
- opts_find_storage_pool_sources_as, info_find_storage_pool_sources_as},
-{"find-storage-pool-sources", cmdPoolDiscoverSources,
- opts_find_storage_pool_sources, info_find_storage_pool_sources},
 {"freecell", cmdFreecell, opts_freecell, info_freecell},
 {"hostname", cmdHostname, NULL, info_hostname},
 {"managedsave", cmdManagedSave, opts_managedsave, info_managedsave},
@@ -10003,6 +,10 @@ static const vshCmdDef domMonitoringCmds[] = {
 };

 static const vshCmdDef storagePoolCmds[] = {
+{"find-storage-pool-sources-as", cmdPoolDiscoverSourcesAs,
+ opts_find_storage_pool_sources_as, info_find_storage_pool_sources_as},
+{"find-storage-pool-sources", cmdPoolDiscoverSources,
+ opts_find_storage_pool_sources, info_find_storage_pool_sources},
 {"pool-autostart", cmdPoolAutostart, opts_pool_autostart, 
info_pool_autostart},
 {"pool-build", cmdPoolBuild, opts_pool_build, info_pool_build},
 {"pool-create-as", cmdPoolCreateAs, opts_pool_X_as, info_pool_create_as},
--
1.7.3.2

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


Re: [libvirt] [PATCH v3 4/5] Add a watchdog action `dump'

2010-12-01 Thread Hu Tao
On Tue, Nov 30, 2010 at 03:21:36PM -0700, Eric Blake wrote:
<...snip...>
> >  
> > -libvirt_qemu_la_SOURCES = libvirt-qemu.c
> > +libvirt_qemu_la_SOURCES = libvirt-qemu.c util/threadpool.c
> 
> Why is this change necessary?  Shouldn't libvirt_util.la already include
> threadpool.c, and the qemu driver already be linking with libvirt_util.la?

Is this ok?

-libvirt_driver_qemu_la_LIBADD = $(NUMACTL_LIBS)
+libvirt_driver_qemu_la_LIBADD = $(NUMACTL_LIBS) ../src/libvirt_util.la

Or link will fail:

  CCLD   libvirtd
libvirtd-libvirtd.o: In function `qemudRunLoop':
/mnt/data/kernel/libvirt/daemon/libvirtd.c:2229: undefined reference to 
`virWorkerPoolNew'
/mnt/data/kernel/libvirt/daemon/libvirtd.c:2287: undefined reference to 
`virWorkerPoolFree'
libvirtd-libvirtd.o: In function `qemudDispatchClientRead':
/mnt/data/kernel/libvirt/daemon/libvirtd.c:1778: undefined reference to 
`virWorkerPoolSendJob'
../src/.libs/libvirt_driver_qemu.a(libvirt_driver_qemu_la-qemu_driver.o): In 
function `qemuHandleDomainWatchdog':
/mnt/data/kernel/libvirt/src/qemu/qemu_driver.c:1224: undefined reference to 
`virWorkerPoolSendJob'
../src/.libs/libvirt_driver_qemu.a(libvirt_driver_qemu_la-qemu_driver.o): In 
function `qemudShutdown':
/mnt/data/kernel/libvirt/src/qemu/qemu_driver.c:2147: undefined reference to 
`virWorkerPoolFree'
../src/.libs/libvirt_driver_qemu.a(libvirt_driver_qemu_la-qemu_driver.o): In 
function `qemudStartup':
/mnt/data/kernel/libvirt/src/qemu/qemu_driver.c:2007: undefined reference to 
`virWorkerPoolNew'
collect2: ld returned 1 exit status

 
<...snip...>

> > +
> >  virDomainObjUnlock(vm);
> >  
> >  if (watchdogEvent || lifecycleEvent) {
> > @@ -1788,6 +1807,9 @@ qemudStartup(int privileged) {
> >  if (virAsprintf(&qemu_driver->snapshotDir,
> >  "%s/lib/libvirt/qemu/snapshot", LOCALSTATEDIR) == 
> > -1)
> >  goto out_of_memory;
> > +if (virAsprintf(&qemu_driver->autoDumpPath,
> > +"%s/lib/libvirt/qemu/dump", LOCALSTATEDIR) == -1)
> 
> At first glance, I'm not quite sure why autoDumpPath is configurable but
> not snapshotDir.  I guess it has to do with the fact that snapshots are
> under libvirt control (the user does not need to know that they exist),
> but dump files are intended to be consumed by the user (so the user
> should be able to specify an alternate location).

Yes.

> 
> > +goto out_of_memory;
> >  } else {
> >  uid_t uid = geteuid();
> >  char *userdir = virGetUserDirectory(uid);
> > @@ -1816,6 +1838,8 @@ qemudStartup(int privileged) {
> >  goto out_of_memory;
> >  if (virAsprintf(&qemu_driver->snapshotDir, "%s/qemu/snapshot", 
> > base) == -1)
> >  goto out_of_memory;
> > +if (virAsprintf(&qemu_driver->autoDumpPath, "%s/qemu/dump", base) 
> > == -1)
> > +goto out_of_memory;
> 
> However, it does raise an issue.  Is qemu.conf only for privileged
> users, or do we have to worry about allowing non-privileged users also
> be able to pick up an alternate directory (especially since they can't
> dump to /var/log/...)?

qemu.conf is only for privileged users, but non-privileged users who
need to analyze dump files should ask admin to specify an auto-dump
directory they have right to read.

Or do you have a better idea?


-- 
Thanks,
Hu Tao

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


[libvirt] [PATCH 0/2] smbios fixes

2010-12-01 Thread Eric Blake
In testing , I noticed a couple of problems.
First, qemu rejected the command line we gave it (invalid UUID);
ifixingthat showed that all other arguments were being given literal
"" which then made the guest smbios differ from the host.  Second,
the qemu option -smbios type=1,family=string wasn't supported, which
lead to a spurious difference between host and guest.

Meanwhile, qemu has a bug where '-smbios type=1,uuid=uuid' must parse
as a valid uuid, but is otherwise ignored.  The current qemu.git code
base _only_ sets smbios uuid from the '-uuid uuid' argument.  I've
filed a bug against the qemu folks asking whether this is intended (in
which case we have to modify libvirt to change the -uuid argument it
outputs when smbios is specified), or an oversight (hopefully the
latter, since it's still nice to correlate
/var/log/libvirt/qemu/log with the XML uuid even when that differs
from the smbios uuid presented to the guest.)

Eric Blake (2):
  qemu: avoid adding "" in smbios arguments
  smbios: support system family

 docs/schemas/domain.rng |1 +
 src/conf/domain_conf.c  |9 +++-
 src/qemu/qemu_conf.c|   26 +-
 src/util/sysinfo.c  |7 ++
 src/util/sysinfo.h  |1 +
 tests/qemuxml2argvdata/qemuxml2argv-smbios.args |2 +-
 tests/qemuxml2argvdata/qemuxml2argv-smbios.xml  |2 +
 7 files changed, 35 insertions(+), 13 deletions(-)

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


[libvirt] [PATCH 3/2] smbios: allow () in smbios strings

2010-12-01 Thread Eric Blake
* docs/schemas/domain.rng (sysinf-value): Expand pattern.
* tests/qemuxml2argvdata/qemuxml2argv-smbios.xml: Prefer '' over
"" for attribute values.  Copy real hardware values.
* tests/qemuxml2argvdata/qemuxml2argv-smbios.args: Likewise.
---

This should address some of the issues I raised in
https://www.redhat.com/archives/libvir-list/2010-December/msg00086.html
(still missing is docs/formatdomain.html.in for all of this).

 docs/schemas/domain.rng |2 +-
 tests/qemuxml2argvdata/qemuxml2argv-smbios.args |2 +-
 tests/qemuxml2argvdata/qemuxml2argv-smbios.xml  |   22 +++---
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 6c47ea0..d08d763 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -1879,7 +1879,7 @@

   
 
-  [a-zA-Z0-9/\-_\. ]+
+  [a-zA-Z0-9/\-_\. \(\)]+
 
   

diff --git a/tests/qemuxml2argvdata/qemuxml2argv-smbios.args 
b/tests/qemuxml2argvdata/qemuxml2argv-smbios.args
index b5e4783..12ef04f 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-smbios.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-smbios.args
@@ -1 +1 @@
-LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M 
pc -m 214 -smp 1 -smbios type=0,vendor=QEmu/KVM,version=0.13 -smbios 
type=1,manufacturer=Fedora,product=Virt-Manager,version=0.8.2-3.fc14,serial=32dfcb37-5af1-552b-357c-be8c3aa38310,uuid=c7a5fdbd-edaf-9455-926a-d65c16db1809,sku=1234567890,family=Red
 Hat -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c 
-hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M 
pc -m 214 -smp 1 -smbios type=0,vendor=LENOVO,version=6FET82WW (3.12 ) -smbios 
type=1,manufacturer=Fedora,product=Virt-Manager,version=0.8.2-3.fc14,serial=32dfcb37-5af1-552b-357c-be8c3aa38310,uuid=c7a5fdbd-edaf-9455-926a-d65c16db1809,sku=1234567890,family=Red
 Hat -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c 
-hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-smbios.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-smbios.xml
index 45b6dba..23ec1a7 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-smbios.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-smbios.xml
@@ -4,25 +4,25 @@
   219200
   219200
   1
-  
+  
 
-  QEmu/KVM
-  0.13
+  LENOVO
+  6FET82WW (3.12 )
 
 
-  Fedora
-  Virt-Manager
-  0.8.2-3.fc14
-  32dfcb37-5af1-552b-357c-be8c3aa38310
-  c7a5fdbd-edaf-9455-926a-d65c16db1809
-  1234567890
-  Red Hat
+  Fedora
+  Virt-Manager
+  0.8.2-3.fc14
+  32dfcb37-5af1-552b-357c-be8c3aa38310
+  c7a5fdbd-edaf-9455-926a-d65c16db1809
+  1234567890
+  Red Hat
 
   
   
 hvm
 
-
+
   
   
   destroy
-- 
1.7.1

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


[libvirt] [PATCH 1/2] qemu: avoid adding "" in smbios arguments

2010-12-01 Thread Eric Blake
The log lists things like -smbios type=1,vendor="Red Hat", which
is great for shell parsing, but not so great when you realize that
execve() then passes those literal "" on as part of the command
line argument, such that qemu sets SMBIOS with extra literal quotes.

The eventual addition of virCommand is needed before we have the API
to shell-quote a string representation of a command line, so that the
log can still be pasted into a shell, but without inserting extra
bytes into the execve() arguments.

* src/qemu/qemu_conf.c (qemuBuildSmbiosBiosStr)
(qemuBuildSmbiosSystemStr): Qemu doesn't like quotes around uuid
arguments, and the remaining quotes are passed literally to
smbios, making  inaccurate.  Removing the
quotes makes the log harder to parse, but that can be fixed later
with virCommand improvements.
* tests/qemuxml2argvdata/qemuxml2argv-smbios.args: 'Fix' test; it
will need fixing again once virCommand learns how to shell-quote a
potential command line.
---
 src/qemu/qemu_conf.c|   20 ++--
 tests/qemuxml2argvdata/qemuxml2argv-smbios.args |2 +-
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 7cd0603..50c1e6c 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -3613,16 +3613,16 @@ static char *qemuBuildSmbiosBiosStr(virSysinfoDefPtr 
def)

 /* 0:Vendor */
 if (def->bios_vendor)
-virBufferVSprintf(&buf, ",vendor=\"%s\"", def->bios_vendor);
+virBufferVSprintf(&buf, ",vendor=%s", def->bios_vendor);
 /* 0:BIOS Version */
 if (def->bios_version)
-virBufferVSprintf(&buf, ",version=\"%s\"", def->bios_version);
+virBufferVSprintf(&buf, ",version=%s", def->bios_version);
 /* 0:BIOS Release Date */
 if (def->bios_date)
-virBufferVSprintf(&buf, ",date=\"%s\"", def->bios_date);
+virBufferVSprintf(&buf, ",date=%s", def->bios_date);
 /* 0:System BIOS Major Release and 0:System BIOS Minor Release */
 if (def->bios_release)
-virBufferVSprintf(&buf, ",release=\"%s\"", def->bios_release);
+virBufferVSprintf(&buf, ",release=%s", def->bios_release);

 if (virBufferError(&buf)) {
 virReportOOMError();
@@ -3649,23 +3649,23 @@ static char *qemuBuildSmbiosSystemStr(virSysinfoDefPtr 
def)

 /* 1:Manufacturer */
 if (def->system_manufacturer)
-virBufferVSprintf(&buf, ",manufacturer=\"%s\"",
+virBufferVSprintf(&buf, ",manufacturer=%s",
   def->system_manufacturer);
  /* 1:Product Name */
 if (def->system_product)
-virBufferVSprintf(&buf, ",product=\"%s\"", def->system_product);
+virBufferVSprintf(&buf, ",product=%s", def->system_product);
 /* 1:Version */
 if (def->system_version)
-virBufferVSprintf(&buf, ",version=\"%s\"", def->system_version);
+virBufferVSprintf(&buf, ",version=%s", def->system_version);
 /* 1:Serial Number */
 if (def->system_serial)
-virBufferVSprintf(&buf, ",serial=\"%s\"", def->system_serial);
+virBufferVSprintf(&buf, ",serial=%s", def->system_serial);
 /* 1:UUID */
 if (def->system_uuid)
-virBufferVSprintf(&buf, ",uuid=\"%s\"", def->system_uuid);
+virBufferVSprintf(&buf, ",uuid=%s", def->system_uuid);
 /* 1:SKU Number */
 if (def->system_sku)
-virBufferVSprintf(&buf, ",sku=\"%s\"", def->system_sku);
+virBufferVSprintf(&buf, ",sku=%s", def->system_sku);

 if (virBufferError(&buf)) {
 virReportOOMError();
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-smbios.args 
b/tests/qemuxml2argvdata/qemuxml2argv-smbios.args
index d5bd289..bd3ede4 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-smbios.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-smbios.args
@@ -1 +1 @@
-LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M 
pc -m 214 -smp 1 -smbios type=0,vendor="QEmu/KVM",version="0.13" -smbios 
type=1,manufacturer="Fedora",product="Virt-Manager",version="0.8.2-3.fc14",serial="32dfcb37-5af1-552b-357c-be8c3aa38310",uuid="c7a5fdbd-edaf-9455-926a-d65c16db1809"
 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda 
/dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M 
pc -m 214 -smp 1 -smbios type=0,vendor=QEmu/KVM,version=0.13 -smbios 
type=1,manufacturer=Fedora,product=Virt-Manager,version=0.8.2-3.fc14,serial=32dfcb37-5af1-552b-357c-be8c3aa38310,uuid=c7a5fdbd-edaf-9455-926a-d65c16db1809
 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda 
/dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
-- 
1.7.1

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


[libvirt] [PATCH 2/2] smbios: support system family

2010-12-01 Thread Eric Blake
* docs/schemas/domain.rng (sysinfo-system-name): Also allow
family.
* src/util/sysinfo.h (struct _virSysinfoDef): Add system_family.
* src/conf/domain_conf.c (virSysinfoParseXML)
(virDomainSysinfoDefFormat): Support it.
* src/util/sysinfo.c (virSysinfoDefFree, virSysinfoRead): Likewise.
* src/qemu/qemu_conf.c (qemuBuildSmbiosSystemStr): Likewise.
* tests/qemuxml2argvdata/qemuxml2argv-smbios.xml: Adjust test.
* tests/qemuxml2argvdata/qemuxml2argv-smbios.args: Likewise.
---
 docs/schemas/domain.rng |1 +
 src/conf/domain_conf.c  |9 -
 src/qemu/qemu_conf.c|6 +-
 src/util/sysinfo.c  |7 +++
 src/util/sysinfo.h  |1 +
 tests/qemuxml2argvdata/qemuxml2argv-smbios.args |2 +-
 tests/qemuxml2argvdata/qemuxml2argv-smbios.xml  |2 ++
 7 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index fb44335..6c47ea0 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -1873,6 +1873,7 @@
   serial
   uuid
   sku
+  family
 
   

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3f14cee..91d7cce 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3626,6 +3626,8 @@ virSysinfoParseXML(const xmlNodePtr node,
 virXPathString("string(system/ent...@name='uuid'])", ctxt);
 def->system_sku =
 virXPathString("string(system/ent...@name='sku'])", ctxt);
+def->system_family =
+virXPathString("string(system/ent...@name='family'])", ctxt);

 cleanup:
 VIR_FREE(type);
@@ -6426,7 +6428,8 @@ virDomainSysinfoDefFormat(virBufferPtr buf,
 }
 if ((def->system_manufacturer != NULL) || (def->system_product != NULL) ||
 (def->system_version != NULL) || (def->system_serial != NULL) ||
-(def->system_uuid != NULL) || (def->system_sku != NULL)) {
+(def->system_uuid != NULL) || (def->system_sku != NULL) ||
+(def->system_family != NULL)) {
 virBufferAddLit(buf, "\n");
 if (def->system_manufacturer != NULL)
 virBufferEscapeString(buf,
@@ -6452,6 +6455,10 @@ virDomainSysinfoDefFormat(virBufferPtr buf,
 virBufferEscapeString(buf,
   "  %s\n",
   def->system_sku);
+if (def->system_family != NULL)
+virBufferEscapeString(buf,
+  "  %s\n",
+  def->system_family);
 virBufferAddLit(buf, "\n");
 }

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 50c1e6c..ad4d4fc 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -3642,7 +3642,8 @@ static char *qemuBuildSmbiosSystemStr(virSysinfoDefPtr 
def)

 if ((def->system_manufacturer == NULL) && (def->system_sku == NULL) &&
 (def->system_product == NULL) && (def->system_uuid == NULL) &&
-(def->system_version == NULL) && (def->system_serial == NULL))
+(def->system_version == NULL) && (def->system_serial == NULL) &&
+(def->system_family == NULL))
 return(NULL);

 virBufferAddLit(&buf, "type=1");
@@ -3666,6 +3667,9 @@ static char *qemuBuildSmbiosSystemStr(virSysinfoDefPtr 
def)
 /* 1:SKU Number */
 if (def->system_sku)
 virBufferVSprintf(&buf, ",sku=%s", def->system_sku);
+/* 1:Family */
+if (def->system_family)
+virBufferVSprintf(&buf, ",family=%s", def->system_family);

 if (virBufferError(&buf)) {
 virReportOOMError();
diff --git a/src/util/sysinfo.c b/src/util/sysinfo.c
index 8ad98fe..cf41773 100644
--- a/src/util/sysinfo.c
+++ b/src/util/sysinfo.c
@@ -68,6 +68,7 @@ void virSysinfoDefFree(virSysinfoDefPtr def)
 VIR_FREE(def->system_serial);
 VIR_FREE(def->system_uuid);
 VIR_FREE(def->system_sku);
+VIR_FREE(def->system_family);
 VIR_FREE(def);
 }

@@ -217,6 +218,12 @@ virSysinfoRead(void) {
 if ((eol) && ((ret->system_sku = strndup(cur, eol - cur)) == NULL))
 goto no_memory;
 }
+if ((cur = strstr(base, "Family: ")) != NULL) {
+cur += 8;
+eol = strchr(cur, '\n');
+if ((eol) && ((ret->system_family = strndup(cur, eol - cur)) == NULL))
+goto no_memory;
+}

 cleanup:
 VIR_FREE(outbuf);
diff --git a/src/util/sysinfo.h b/src/util/sysinfo.h
index 611d54e..1af7ef6 100644
--- a/src/util/sysinfo.h
+++ b/src/util/sysinfo.h
@@ -49,6 +49,7 @@ struct _virSysinfoDef {
 char *system_serial;
 char *system_uuid;
 char *system_sku;
+char *system_family;
 };

 virSysinfoDefPtr virSysinfoRead(void);
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-smbios.args 
b/tests/qemuxml2argvdata/qemuxml2argv-smbios.args
index bd3ede4..b5e4783 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-smbios.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv

[libvirt] [PATCH] maint: update .gitignore

2010-12-01 Thread Eric Blake
* .gitignore: Ignore recent built file, sort.
---

Pushing under the trivial rule.  Noticed after a clean bootstrap.

 .gitignore |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/.gitignore b/.gitignore
index 12ae5e3..5518d2d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -50,10 +50,12 @@
 /po/
 /proxy/
 /tests/*.log
+/tests/cputest
 /tests/nwfilterxml2xmltest
 /update.log
 Makefile
 Makefile.in
+TAGS
 coverage
 cscope.files
 cscope.out
@@ -61,4 +63,3 @@ results.log
 stamp-h
 stamp-h.in
 stamp-h1
-TAGS
-- 
1.7.1

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


Re: [libvirt] [PATCHv2 3/8] Introduce new APIs for spawning processes

2010-12-01 Thread Eric Blake
On 11/23/2010 04:49 PM, Eric Blake wrote:
> From: Daniel P. Berrange 
> 
> This introduces a new set of APIs in src/util/command.h
> to use for invoking commands. This is intended to replace
> all current usage of virRun and virExec variants, with a
> more flexible and less error prone API.
> 
> +/*
> + * Call after adding all arguments and environment settings, but before
> + * Run/RunAsync, to immediately output the environment and arguments of
> + * cmd to logfd.  If virCommandRun cannot succeed (because of an
> + * out-of-memory condition while building cmd), nothing will be logged.
> + */
> +void virCommandWriteArgLog(virCommandPtr cmd,
> +   int logfd);
> +
> +/*
> + * Call after adding all arguments and environment settings, but before
> + * Run/RunAsync, to return a string representation of the environment and
> + * arguments of cmd.  If virCommandRun cannot succeed (because of an
> + * out-of-memory condition while building cmd), NULL will be returned.
> + * Caller is responsible for freeing the resulting string.
> + */
> +char *virCommandToString(virCommandPtr cmd) ATTRIBUTE_RETURN_CHECK;

Bummer.  Just realized that these functions should probably be modified
to take another parameter that controls whether the output should be
quoted for shell use.

Basically, I just tested the recent addition of ,
and found out that it has a bug: it takes the host string (which may
have spaces), and passes it to the qemu command line as:

-smbios 'type=0,version="6FET82WW (3.12 )"'

which means that the guest gets literal "" in the SMBIOS string, whereas
the host did not have them, such that it is not a true host mirroring as
intended.  But in the /var/log/libvirt/qemu/...log, the argument only
shows up as:

-smbios type=0,version="6FET82WW (3.12 )"

which, when pasted literally into a shell, does the right thing.

Therefore, adding the ability to shell-quote the log will make it easier
to log complex shell commands, where we really did intend to pass shell
metacharacters via a single argument.

I'll have to fold that in to my next revision.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCHv2 3/8] Introduce new APIs for spawning processes

2010-12-01 Thread Matthias Bolte
2010/11/24 Eric Blake :
> From: Daniel P. Berrange 
>
> This introduces a new set of APIs in src/util/command.h
> to use for invoking commands. This is intended to replace
> all current usage of virRun and virExec variants, with a
> more flexible and less error prone API.
>
> * src/util/command.c: New file.
> * src/util/command.h: New header.
> * src/Makefile.am (UTIL_SOURCES): Build it.
> * src/libvirt_private.syms: Export symbols internally.
> * tests/commandtest.c: New test.
> * tests/Makefile.am (check_PROGRAMS): Run it.
> * tests/commandhelper.c: Auxiliary program.
> * tests/commanddata/test2.log - test15.log: New expected outputs.
> * cfg.mk (useless_free_options): Add virCommandFree.
> * po/POTFILES.in: New translation.
> * .x-sc_avoid_write: Add exemption.
> * tests/.gitignore: Ignore new built file.
> ---
>
> v2: add virCommandTransferFD, virCommandToString, virCommandAddArgFormat,
> virCommandNewArgList, virCommandWriteArgLog, virCommandNonblockingFDs.
> Fix virCommandRunAsync and virCommandFree to free transfered FDs.
> Add a bit more test exposure.
>

> diff --git a/cfg.mk b/cfg.mk
> index dea8301..6312632 100644
> --- a/cfg.mk
> +++ b/cfg.mk
> @@ -77,6 +77,7 @@ useless_free_options =                                \
>   --name=virCapabilitiesFreeHostNUMACell       \
>   --name=virCapabilitiesFreeMachines           \
>   --name=virCgroupFree                         \
> +  --name=virCommandFree                                \
>   --name=virConfFreeList                       \
>   --name=virConfFreeValue                      \
>   --name=virDomainChrDefFree                   \

You should also add virCommandError to the msg_gen_function list.

> diff --git a/src/util/command.c b/src/util/command.c
> new file mode 100644
> index 000..948a957
> --- /dev/null
> +++ b/src/util/command.c

> +/*
> + * Create a new command with a NULL terminated
> + * set of args, taking binary from argv[0]
> + */

s/argv[0]/args[0]/

> +virCommandPtr
> +virCommandNewArgs(const char *const*args)



> +
> +/*
> + * Capture the child's stdout to a string buffer
> + */
> +void
> +virCommandSetOutputBuffer(virCommandPtr cmd, char **outbuf)
> +{
> +    if (!cmd || cmd->has_error)
> +        return;
> +
> +    if (cmd->outfd != -1) {

To detect double assignment properly you need to check for this I think:

if (cmd->outfd != -1 || cmd->outfdptr || cmd->outbuf) {

> +        cmd->has_error = -1;
> +        VIR_DEBUG0("cannot specify output twice");
> +        return;
> +    }
> +
> +    cmd->outbuf = outbuf;
> +    cmd->outfdptr = &cmd->outfd;
> +}
> +
> +
> +/*
> + * Capture the child's stderr to a string buffer
> + */
> +void
> +virCommandSetErrorBuffer(virCommandPtr cmd, char **errbuf)
> +{
> +    if (!cmd || cmd->has_error)
> +        return;
> +
> +    if (cmd->errfd != -1) {

The same pattern as in virCommandSetOutputBuffer:

if (cmd->errfd != -1 || cmd->errfdptr || cmd->errbuf) {

> +        cmd->has_error = -1;
> +        VIR_DEBUG0("cannot specify stderr twice");
> +        return;
> +    }
> +
> +    cmd->errbuf = errbuf;
> +    cmd->errfdptr = &cmd->errfd;
> +}
> +
> +
> +/*
> + * Attach a file descriptor to the child's stdin
> + */
> +void
> +virCommandSetInputFD(virCommandPtr cmd, int infd)
> +{
> +    if (!cmd || cmd->has_error)
> +        return;
> +
> +    if (infd < 0 || cmd->inbuf) {

I think you meant to check here for this instead:

if (cmd->infd != -1 || cmd->inbuf) {

> +        cmd->has_error = -1;
> +        VIR_DEBUG0("cannot specify input twice");
> +        return;
> +    }
> +
> +    cmd->infd = infd;
> +}
> +
> +
> +/*
> + * Attach a file descriptor to the child's stdout
> + */
> +void
> +virCommandSetOutputFD(virCommandPtr cmd, int *outfd)
> +{
> +    if (!cmd || cmd->has_error)
> +        return;
> +
> +    if (!outfd || cmd->outfd != -1) {

I think you meant to check here for this instead:

if (cmd->outfd != -1 || cmd->outfdptr || cmd->outbuf) {

> +        cmd->has_error = -1;
> +        VIR_DEBUG0("cannot specify output twice");
> +        return;
> +    }
> +
> +    cmd->outfdptr = outfd;
> +}
> +
> +
> +/*
> + * Attach a file descriptor to the child's stderr
> + */
> +void
> +virCommandSetErrorFD(virCommandPtr cmd, int *errfd)
> +{
> +    if (!cmd || cmd->has_error)
> +        return;
> +
> +    if (!errfd || cmd->errfd != -1) {

I think you meant to check here for this instead:

if (cmd->errfd != -1 || cmd->errfdptr || cmd->errbuf) {

> +        cmd->has_error = -1;
> +        VIR_DEBUG0("cannot specify stderr twice");
> +        return;
> +    }
> +
> +    cmd->errfdptr = errfd;
> +}

> +
> +/*
> + * Call after adding all arguments and environment settings, but before
> + * Run/RunAsync, to immediately output the environment and arguments of
> + * cmd to logfd.  If virCommandRun cannot succeed (because of an
> + * out-of-memory condition while building cmd), nothing will be logged.
> + */
> +void
> +virCommandWriteArgLog(virCommandPtr cmd, int logfd)
> +{
> +    in

Re: [libvirt] Release of libvirt 0.8.6

2010-12-01 Thread Diego Elio Pettenò
Il giorno gio, 02/12/2010 alle 05.47 +1100, Justin Clift ha scritto:
> Concept wise, do you reckon something like this would work:

Yes that looks perfect to me.

-- 
Diego Elio Pettenò — “Flameeyes”
http://blog.flameeyes.eu/

If you found a .asc file in this mail and know not what it is,
it's a GnuPG digital signature: http://www.gnupg.org/

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

Re: [libvirt] [PATCH] schemas: Fix cpu element schema

2010-12-01 Thread Eric Blake
On 12/01/2010 01:27 PM, Jiri Denemark wrote:
>>> @@ -1745,6 +1745,8 @@
>>>  
>>>  
>>>
>>> +
>>> +
>>>
>>
>> ACK; makes it so that either one can be used in isolation, instead of a
>> both-or-none approach.  Do we have a corresponding .xml file somewhere
>> in the tests/ hierarchy that will test this?
> 
> Yes, it's included in
> [PATCH 2/2] tests: Add tests for CPU selection in qemu driver
> 
> That's how I found this error in the schema.

Good to know.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] schemas: Fix cpu element schema

2010-12-01 Thread Jiri Denemark
> > @@ -1745,6 +1745,8 @@
> >  
> >  
> >
> > +
> > +
> >
> 
> ACK; makes it so that either one can be used in isolation, instead of a
> both-or-none approach.  Do we have a corresponding .xml file somewhere
> in the tests/ hierarchy that will test this?

Yes, it's included in
[PATCH 2/2] tests: Add tests for CPU selection in qemu driver

That's how I found this error in the schema.

Jirka

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


Re: [libvirt] [PATCHv2 2/8] util: fix saferead type

2010-12-01 Thread Matthias Bolte
2010/11/24 Eric Blake :
> * src/util/util.c (saferead): Fix return type.
> (safewrite): Fix indentation.
> ---
>
> v2: new patch.  Not really essential to the series, so much as a
> trivial cleanup I noticed while in the area.
>

ACK.

Matthias

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

Re: [libvirt] [PATCHv2 1/8] util: add virVasprintf

2010-12-01 Thread Matthias Bolte
2010/11/24 Eric Blake :
> * src/util/util.h (virVasprintf): New declaration.
> * src/util/util.c (virVasprintf): New function.
> (virAsprintf): Use it.
> * src/util/virtaudit.c (virAuditSend): Likewise.
> * src/libvirt_private.syms: Export it.
> * cfg.mk (sc_prohibit_asprintf): Also prohibit vasprintf.
> * .x-sc_prohibit_asprintf: Add exemption.
> ---
>
> v2: new patch; makes virCommandAddArgFormat possible in later patch
>

ACK.

Matthias

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


Re: [libvirt] [PATCH 4/8] Introduce generic objects for building XDR RPC servers/clients

2010-12-01 Thread Eric Blake
On 12/01/2010 10:26 AM, Daniel P. Berrange wrote:
> Introduces a set of generic objects which are to be used in
> building RPC servers/clients based on XDR.
> 
>  - virNetMessageHeader - standardize the XDR format for any
>RPC program. Copied from remote protocol for back compat
> 
>  - virNetMessage - Provides a buffer for (de-)serializing
>messages, and a copy of the decoded virNetMessageHeader.
>Provides APIs for encoding/decoding message headers and
>payloads, thus isolating all the XDR api calls in one
>file. Callers no longer need to use XDR themselves.
> 
>  - virNetSocket - a wrapper around a socket file descriptor,
>to simplify creation of new sockets, both for clients and
>services. Encapsulates all the hairy getaddrinfo code
>and sockaddr manipulation.  Will eventually include
>transparent support for TLS and SASL encoding of data
> 
>  - virNetTLSContext - encapsulates the credentials required
>to setup TLS sessions. eg the set of x509 certificates
>and keys, optional DH parameters and x509 DName whitelist
>Provides APIs for easily validating certificates from a
>TLS session
> 
>  - virNetTLSSession - encapsulates the TLS session handling,
>so that callers no longer have a direct dependancy on
>gnutls. This will facilitate adding alternate TLS impls.
>Makes the read/write TLS functions work with same
>semantics as the native socket read/write functions. ie
>they set errno, instead of a gnutls specific error code.

Is it worth introducing these in separate patches, instead of all in one
go?  At any rate, this is big enough that I haven't reviewed it in
detail yet, but the concept of factoring out the common code seems nice.

Let's make a deal :)  If you look at my virCommand series, I'll look at
this!

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 3/8] Tweak daemon event debug to include errno

2010-12-01 Thread Eric Blake
On 12/01/2010 10:26 AM, Daniel P. Berrange wrote:
> * daemon/event.c: Include errno in debug info upon poll() failure
> ---
>  daemon/event.c |3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/daemon/event.c b/daemon/event.c
> index a983b35..0920748 100644
> --- a/daemon/event.c
> +++ b/daemon/event.c
> @@ -576,13 +576,14 @@ int virEventRunOnce(void) {
>   retry:
>  EVENT_DEBUG("Poll on %d handles %p timeout %d", nfds, fds, timeout);
>  ret = poll(fds, nfds, timeout);
> -EVENT_DEBUG("Poll got %d event", ret);
>  if (ret < 0) {
> +EVENT_DEBUG("Poll got error event %d", errno);
>  if (errno == EINTR) {
>  goto retry;
>  }
>  goto error_unlocked;
>  }
> +EVENT_DEBUG("Poll got %d event(s)", ret);

ACK; independently useful, if you want to push now.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 2/8] Fix memory leak in logging setup

2010-12-01 Thread Eric Blake
On 12/01/2010 10:26 AM, Daniel P. Berrange wrote:
> The logging setup requires const char * strings, but the
> virLogSetFromEnv() strdup's the env variables, thus causing
> a memory leak
> 
> * src/util/logging.c: Avoid strdup'ing env variables
> ---
>  src/util/logging.c |4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/util/logging.c b/src/util/logging.c
> index d65dec0..83cc358 100644
> --- a/src/util/logging.c
> +++ b/src/util/logging.c
> @@ -980,8 +980,8 @@ void virLogSetFromEnv(void) {
>  virLogParseDefaultPriority(debugEnv);
>  debugEnv = getenv("LIBVIRT_LOG_FILTERS");
>  if (debugEnv && *debugEnv)
> -virLogParseFilters(strdup(debugEnv));
> +virLogParseFilters(debugEnv);

ACK; independently useful to push now, even if the rest of your series
is not ready for prime time.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 1/8] Thread pool impl

2010-12-01 Thread Eric Blake
On 12/01/2010 10:26 AM, Daniel P. Berrange wrote:
> From: Hu Tao 

Not sure whether Daniel or Hu will be the next person to post an
improvement of this patch.  Some of my comments are repeated from Hu's
first attempt, although many of them have been addressed in updating to
libvirt APIs.

> 
> * src/util/threadpool.c, src/util/threadpool.h: Thread pool
>   implementation
> * src/Makefile.am: Build thread pool
> ---
>  src/Makefile.am   |1 +
>  src/util/threadpool.c |  178 
> +
>  src/util/threadpool.h |   23 ++
>  3 files changed, 202 insertions(+), 0 deletions(-)
>  create mode 100644 src/util/threadpool.c
>  create mode 100644 src/util/threadpool.h

> +++ b/src/util/threadpool.c
> @@ -0,0 +1,178 @@

Still missing copyright blurb.

> +
> +struct _virThreadPool {
> +int quit;

s/int/bool/ (which means including  earlier)


> +virThreadPoolPtr virThreadPoolNew(size_t minWorkers,
> +  size_t maxWorkers,
> +  virThreadPoolJobFunc func,
> +  void *opaque)
> +{
> +virThreadPoolPtr pool;
> +int i;

s/int/size_t/

> +void virThreadPoolFree(virThreadPoolPtr pool)
> +{

if (!pool) return;

> +virMutexLock(&pool->mutex);

What happens if the reason we called this was because virMutexInit
failed during virThreadPoolNew?  Is it still safe to blindly call
virMutexLock on a broken mutex?

> +pool->quit = 1;

s/1/true/

> +if (pool->nWorkers > 0) {
> +virCondBroadcast(&pool->cond);
> +if (virCondWait(&pool->quit_cond, &pool->mutex) < 0)
> +{}

Is it any better to use "ignore-value.h" and ignore_value(virCondWait),
instead of the empty if () {}?

> +}
> +VIR_FREE(pool->workers);
> +virMutexUnlock(&pool->mutex);

missing cleanups for mutex, cond, quit_cond (virMutexDestroy,
virCondDestroy).  And if you are forcefully quitting while jobs are
still unclaimed, is it possible that jobList might also need freeing, or
is that guaranteed to be taken care of by the virCondWait?

> +VIR_FREE(pool);
> +}
> +
> +int virThreadPoolSendJob(virThreadPoolPtr pool,
> + void *jobData)
> +{
> +virThreadPoolJobPtr job;
> +virThreadPoolJobPtr tmp;
> +
> +virMutexLock(&pool->mutex);
> +if (pool->quit)
> +goto error;
> +
> +if (pool->freeWorkers == 0 &&
> +pool->nWorkers < pool->maxWorkers) {
> +if (VIR_EXPAND_N(pool->workers, pool->nWorkers, 1) < 0) {
> +virReportOOMError();
> +goto error;
> +}
> +
> +if (virThreadCreate(&pool->workers[pool->nWorkers],
> +true,
> +virThreadPoolWorker,
> +pool) < 0)
> +goto error;
> +pool->nWorkers++;

Problem.  VIR_EXPAND_N already incremented pool->nWorkers, but you are
incrementing it again.  You either need to use:

VIR_RESIZE_N(pool->workers, pool->maxworkers, pool->nWorkers, 1)
pool->nWorkers++

or keep the VIR_EXPAND_N, but set pool->workers[pool->nWorkers - 1] to
the created thread.

> +}
> +
> +if (VIR_ALLOC(job) < 0) {
> +virReportOOMError();
> +goto error;
> +}
> +
> +job->data = jobData;
> +
> +tmp = pool->jobList;
> +while (tmp && tmp->next)
> +tmp = tmp->next;
> +if (tmp)
> +tmp->next = job;
> +else
> +pool->jobList = job;

Good - FIFO job ordering.  However, this is O(n) list traversal; would
it make sense to keep track of a list head and list tail pointer, so
that we can have O(1) job insertion, or is that extra bookkeeping not
worth it given that our maximum job queue size is not going to typically
be that large?

> +
> +virCondSignal(&pool->cond);
> +virMutexUnlock(&pool->mutex);
> +
> +return 0;
> +
> +error:
> +virMutexUnlock(&pool->mutex);
> +return -1;
> +}
> diff --git a/src/util/threadpool.h b/src/util/threadpool.h
> new file mode 100644
> index 000..093786f
> --- /dev/null
> +++ b/src/util/threadpool.h
> @@ -0,0 +1,23 @@

Missing copyright blurb.

> +#ifndef __THREADPOOL_H__
> +#define __THREADPOOL_H__

I'd prefer __VIR_THREADPOOL_H__, to avoid potential collisions in the __
namespace.

> +
> +#include 

Wrong header; this should be "threads.h"

> +
> +typedef struct _virThreadPool virThreadPool;
> +typedef virThreadPool *virThreadPoolPtr;
> +
> +typedef void (*virThreadPoolJobFunc)(void *jobdata, void *opaque);
> +
> +virThreadPoolPtr virThreadPoolNew(size_t minWorkers,
> +  size_t maxWorkers,
> +  virThreadPoolJobFunc func,
> +  void *opaque);

ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK

> +
> +void virThreadPoolShutdown(virThreadPoolPtr pool);

ATTRIBUTE_NONNULL(1)

> +
> +void virThreadPoolFree(virThreadPoolPtr pool);

add this to the list of free-like functions in cfg.m

Re: [libvirt] Release of libvirt 0.8.6

2010-12-01 Thread Justin Clift
On 02/12/2010, at 5:26 AM, Diego Elio Pettenò wrote:
> Il giorno gio, 02/12/2010 alle 02.47 +1100, Justin Clift ha scritto:
>> 
>> Looks like it might be time to put some kind of regression testing in
>> place, as a go/no-go release criteria. 
> 
> May I suggest a 1-week (or less) window without merge of new
> features/improvements, announced on a separate (low-traffic) mailinglist
> for packagers to test the release?
> 
> We'd then have time to test whether the code is fine for all of us or
> not.

Concept wise, do you reckon something like this would work:

 + a new libvirt-announce mailing list, low trafic, purely for release
announcements and similar

Along with us announcing a '"release candidate" build through it (instead of the
present approach).  If it looks good after a period of time (a week or something
as you mentioned), then it gets re-released as the actual release.

If something turns up significantly broken, then we respin as a release 
candidate
2 and repeat the process.

?

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


Re: [libvirt] [PATCH] OpenVZ: drop fd leakage

2010-12-01 Thread Guido Günther
On Wed, Dec 01, 2010 at 11:14:01AM -0700, Eric Blake wrote:
> On 12/01/2010 11:06 AM, Guido Günther wrote:
> > Drop unused (and unclosed) errfd and close outfd on exit. Otherwise
> > polling the running domains with virt-manager let's us quickly run out
> > of fds. O.k. to apply?
> 
> ACK.  It will be touched again once my virCommand series is reviewed and
> ported to more places, but we might as well have it working in the meantime.
Pushed. Thanks,
 -- Guido

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


Re: [libvirt] Release of libvirt 0.8.6

2010-12-01 Thread Diego Elio Pettenò
Il giorno gio, 02/12/2010 alle 02.47 +1100, Justin Clift ha scritto:
> 
> Looks like it might be time to put some kind of regression testing in
> place, as a go/no-go release criteria. 

May I suggest a 1-week (or less) window without merge of new
features/improvements, announced on a separate (low-traffic) mailinglist
for packagers to test the release?

We'd then have time to test whether the code is fine for all of us or
not.

[Speaking as the Gentoo maintainer of libvirt]

-- 
Diego Elio Pettenò — “Flameeyes”
http://blog.flameeyes.eu/

If you found a .asc file in this mail and know not what it is,
it's a GnuPG digital signature: http://www.gnupg.org/

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

Re: [libvirt] [PATCH] OpenVZ: drop fd leakage

2010-12-01 Thread Eric Blake
On 12/01/2010 11:06 AM, Guido Günther wrote:
> Drop unused (and unclosed) errfd and close outfd on exit. Otherwise
> polling the running domains with virt-manager let's us quickly run out
> of fds. O.k. to apply?

ACK.  It will be touched again once my virCommand series is reviewed and
ported to more places, but we might as well have it working in the meantime.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] OpenVZ: drop fd leakage

2010-12-01 Thread Guido Günther
Drop unused (and unclosed) errfd and close outfd on exit. Otherwise
polling the running domains with virt-manager let's us quickly run out
of fds. O.k. to apply?
Cheers,
 -- Guido
>From 5ee971803e1bb7dc642c06b63bbbea724bdfd3dc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= 
Date: Wed, 1 Dec 2010 17:43:46 +0100
Subject: [PATCH] OpenVZ: drop fd leackage

Drop unused (and unclosed) errfd and close outfd on exit. Otherwise
polling the running domains with virt-manager let's us quickly run out
of fds.
---
 src/openvz/openvz_driver.c |   25 +
 1 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index b84a56a..a959ab6 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -1387,17 +1387,17 @@ static int openvzListDomains(virConnectPtr conn ATTRIBUTE_UNUSED,
 int veid;
 pid_t pid;
 int outfd = -1;
-int errfd = -1;
 int ret;
 char buf[32];
 char *endptr;
 const char *cmd[] = {VZLIST, "-ovpsid", "-H" , NULL};
 
 ret = virExec(cmd, NULL, NULL,
-  &pid, -1, &outfd, &errfd, VIR_EXEC_NONE);
+  &pid, -1, &outfd, NULL, VIR_EXEC_NONE);
 if (ret == -1) {
 openvzError(VIR_ERR_INTERNAL_ERROR,
 _("Could not exec %s"), VZLIST);
+VIR_FORCE_CLOSE(outfd);
 return -1;
 }
 
@@ -1415,6 +1415,10 @@ static int openvzListDomains(virConnectPtr conn ATTRIBUTE_UNUSED,
 }
 waitpid(pid, NULL, 0);
 
+if (VIR_CLOSE(outfd) < 0) {
+virReportSystemError(errno, "%s", _("failed to close file"));
+return -1;
+}
 return got;
 }
 
@@ -1432,7 +1436,7 @@ static int openvzNumDomains(virConnectPtr conn) {
 static int openvzListDefinedDomains(virConnectPtr conn ATTRIBUTE_UNUSED,
 char **const names, int nnames) {
 int got = 0;
-int veid, outfd = -1, errfd = -1, ret;
+int veid, outfd = -1, ret;
 pid_t pid;
 char vpsname[32];
 char buf[32];
@@ -1441,11 +1445,11 @@ static int openvzListDefinedDomains(virConnectPtr conn ATTRIBUTE_UNUSED,
 
 /* the -S options lists only stopped domains */
 ret = virExec(cmd, NULL, NULL,
-  &pid, -1, &outfd, &errfd, VIR_EXEC_NONE);
+  &pid, -1, &outfd, NULL, VIR_EXEC_NONE);
 if (ret == -1) {
 openvzError(VIR_ERR_INTERNAL_ERROR,
 _("Could not exec %s"), VZLIST);
-return -1;
+goto out;
 }
 
 while (got < nnames) {
@@ -1459,14 +1463,19 @@ static int openvzListDefinedDomains(virConnectPtr conn ATTRIBUTE_UNUSED,
 }
 snprintf(vpsname, sizeof(vpsname), "%d", veid);
 if (!(names[got] = strdup(vpsname)))
-goto no_memory;
+virReportOOMError();
+goto out;
 got ++;
 }
 waitpid(pid, NULL, 0);
+if (VIR_CLOSE(outfd) < 0) {
+virReportSystemError(errno, "%s", _("failed to close file"));
+goto out;
+}
 return got;
 
-no_memory:
-virReportOOMError();
+out:
+VIR_FORCE_CLOSE(outfd);
 for ( ; got >= 0 ; got--)
 VIR_FREE(names[got]);
 return -1;
-- 
1.7.2.3

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

Re: [libvirt] [PATCH 2/2] tests: Add tests for CPU selection in qemu driver

2010-12-01 Thread Eric Blake
On 12/01/2010 07:56 AM, Jiri Denemark wrote:
> ---
> diff --git a/tests/qemuxml2argvdata/qemu.sh b/tests/qemuxml2argvdata/qemu.sh
> new file mode 100755
> index 000..6d5d354
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemu.sh
> @@ -0,0 +1,64 @@
> +#! /bin/sh

> +real_qemu()
> +{
> +if test x$qemu != x; then
> +exec $qemu "$@"
> +else
> +return 1
> +fi
> +}
> +
> +faked_machine()
> +{
> +echo "pc"
> +}

> +case $* in
> +"-M ?")
> +faked_machine
> +;;
> +"-cpu ?")
> +faked_cpu
> +;;
> +*)
> +real_qemu "$@"
> +;;
> +esac

Nice - you can control the output of possible machines and cpus, even if
a qemu upgrade gains support for more names later.

> @@ -223,6 +226,10 @@ mymain(int argc, char **argv)
>  if (!abs_srcdir)
>  abs_srcdir = getcwd(cwd, sizeof(cwd));
>  
> +abs_top_srcdir = getenv("abs_top_srcdir");
> +if (!abs_top_srcdir)
> +abs_top_srcdir = "..";

Not really absolute, is it?  But it matches other tests, and does the
job, so no need to change it.

ACK.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 1/2] tests: Support for faking emulator in qemuxml2argv

2010-12-01 Thread Eric Blake
On 12/01/2010 07:56 AM, Jiri Denemark wrote:
> This patch allows for using custom scripts instead of /usr/bin/qemu
> emulator in domain XML. To do so, one would specify relative path to the
> custom script in . The path needs to be relative to
> qemuxml2argvdata directory and it will be transparently made absolute in
> runtime. The expected command line needs to contain the exact relative
> path as was used in domain XML.

Makes sense as a testing mechanism, while still something we do not want
exposed to normal usage.

> 
> The problem is RelaxNG schema for domain XML only allows for absolute
> path within . To workaround it, an extra '/' must be added at
> the beginning of the path. That is, instead of "./qemu.sh" or
> "../emulator/qemu.sh" one would use "/./qemu.sh" or
> "/../emulator/qemu.sh". The extra slash is removed before further
> processing. I don't like this workaround, it's very ugly but it's the
> best option I was able to come up with. Relaxing domain XML schema is
> not an option IMO.

Agreed - relaxing the schema would leak the notion of a relative
emulator path, which we don't want to do.  The hack looks as good as any
to me, as long as it's well documented in the code as well as the commit
message.

> ---
>  tests/qemuxml2argvtest.c |   18 ++
>  1 files changed, 18 insertions(+), 0 deletions(-)
> 
> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
> index e6174be..dd07001 100644
> --- a/tests/qemuxml2argvtest.c
> +++ b/tests/qemuxml2argvtest.c
> @@ -41,6 +41,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
>  virDomainChrDef monitor_chr;
>  virConnectPtr conn;
>  char *log = NULL;
> +char *emulator = NULL;
>  
>  if (!(conn = virGetConnect()))
>  goto fail;
> @@ -52,6 +53,16 @@ static int testCompareXMLToArgvFiles(const char *xml,
>  VIR_DOMAIN_XML_INACTIVE)))
>  goto fail;
>  
> +if (vmdef->emulator && STRPREFIX(vmdef->emulator, "/.")) {
> +if (!(emulator = strdup(vmdef->emulator + 1)))

In other words, I'd add a comment here explaining that for test purposes
only, we massage particular emulator names.

ACK, with that nit addressed.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] qemu: Use macro for max and min vnc port instead of number

2010-12-01 Thread Eric Blake
On 12/01/2010 05:35 AM, Osier Yang wrote:
> * src/qemu/qemu_driver.c (though MACROS QEMU_VNC_PORT_MAX, and
> QEMU_VNC_PORT_MIN are defined at the beginning, numbers (65535, 5900)
> are still used, replace them)
> 
> ---
>  src/qemu/qemu_driver.c |8 
>  1 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index fcb90a3..f733482 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -2964,7 +2964,7 @@ static int qemudNextFreePort(struct qemud_driver 
> *driver,
>   int startPort) {
>  int i;
> 
> -for (i = startPort ; i < 65535 ; i++) {
> +for (i = startPort ; i < QEMU_VNC_PORT_MAX; i++) {

ACK; pushed.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

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

2010-12-01 Thread Eric Blake
On 12/01/2010 04:00 AM, Jean-Baptiste Rouault wrote:
> ---
>  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;

Hmm; I'm wondering if it would be easier/more concise to use
ATTRIBUTE_UNUSED rather than explicit casts to void.  But it doesn't
bother me to leave it as-is.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] schemas: Fix cpu element schema

2010-12-01 Thread Eric Blake
On 12/01/2010 07:50 AM, Jiri Denemark wrote:
> Both vendor and topology elements are optional.
> ---
>  docs/schemas/domain.rng |2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
> index fb44335..08ebefb 100644
> --- a/docs/schemas/domain.rng
> +++ b/docs/schemas/domain.rng
> @@ -1745,6 +1745,8 @@
>  
>  
>
> +
> +
>

ACK; makes it so that either one can be used in isolation, instead of a
both-or-none approach.  Do we have a corresponding .xml file somewhere
in the tests/ hierarchy that will test this?

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 3/8] Tweak daemon event debug to include errno

2010-12-01 Thread Daniel P. Berrange
* daemon/event.c: Include errno in debug info upon poll() failure
---
 daemon/event.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/daemon/event.c b/daemon/event.c
index a983b35..0920748 100644
--- a/daemon/event.c
+++ b/daemon/event.c
@@ -576,13 +576,14 @@ int virEventRunOnce(void) {
  retry:
 EVENT_DEBUG("Poll on %d handles %p timeout %d", nfds, fds, timeout);
 ret = poll(fds, nfds, timeout);
-EVENT_DEBUG("Poll got %d event", ret);
 if (ret < 0) {
+EVENT_DEBUG("Poll got error event %d", errno);
 if (errno == EINTR) {
 goto retry;
 }
 goto error_unlocked;
 }
+EVENT_DEBUG("Poll got %d event(s)", ret);
 
 virMutexLock(&eventLoop.lock);
 if (virEventDispatchTimeouts() < 0)
-- 
1.7.2.3

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


[libvirt] [PATCH 8/8] Start of a lock manager daemon

2010-12-01 Thread Daniel P. Berrange
This starts the basic framework for a lock manager daemon to
provide guarenteed isolation between VMs using disk images.
It is a simple demo of how the generic RPC server APIs are
to be used
---
 src/Makefile.am |   16 ++
 src/virtlockd.c |  620 +++
 2 files changed, 636 insertions(+), 0 deletions(-)
 create mode 100644 src/virtlockd.c

diff --git a/src/Makefile.am b/src/Makefile.am
index 8986f22..4c9cc79 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1167,6 +1167,22 @@ libvirt_net_client_la_LDFLAGS = \
 libvirt_net_client_la_LIBADD = \
$(CYGWIN_EXTRA_LIBADD)
 
+sbin_PROGRAMS = virtlockd
+
+virtlockd_SOURCES = virtlockd.c
+virtlockd_CFLAGS = \
+   $(AM_CFLAGS)
+virtlockd_LDFLAGS = \
+   $(AM_LDFLAGS) \
+   $(CYGWIN_EXTRA_LDFLAGS) \
+   $(MINGW_EXTRA_LDFLAGS)
+virtlockd_LDADD = \
+   ../gnulib/lib/libgnu.la \
+   libvirt-net-server.la \
+   libvirt-net-rpc.la \
+   libvirt_util.la \
+   $(CYGWIN_EXTRA_LIBADD)
+
 libexec_PROGRAMS =
 
 if WITH_STORAGE_DISK
diff --git a/src/virtlockd.c b/src/virtlockd.c
new file mode 100644
index 000..ec7dd5d
--- /dev/null
+++ b/src/virtlockd.c
@@ -0,0 +1,620 @@
+/*
+ * virtlockd.c: lock management daemon
+ *
+ * Copyright (C) 2006-2010 Red Hat, Inc.
+ * Copyright (C) 2006 Daniel P. Berrange
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: Daniel P. Berrange 
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+
+#include "util.h"
+#include "files.h"
+#include "virterror_internal.h"
+#include "logging.h"
+#include "memory.h"
+#include "conf.h"
+#include "rpc/virnetserver.h"
+#include "threads.h"
+
+#define VIR_FROM_THIS VIR_FROM_NONE
+
+#include "configmake.h"
+
+enum {
+VIR_DAEMON_ERR_NONE = 0,
+VIR_DAEMON_ERR_PIDFILE,
+VIR_DAEMON_ERR_RUNDIR,
+VIR_DAEMON_ERR_INIT,
+VIR_DAEMON_ERR_SIGNAL,
+VIR_DAEMON_ERR_PRIVS,
+VIR_DAEMON_ERR_NETWORK,
+VIR_DAEMON_ERR_CONFIG,
+VIR_DAEMON_ERR_HOOKS,
+
+VIR_DAEMON_ERR_LAST
+};
+
+VIR_ENUM_DECL(virDaemonErr)
+VIR_ENUM_IMPL(virDaemonErr, VIR_DAEMON_ERR_LAST,
+  "Initialization successful",
+  "Unable to obtain pidfile",
+  "Unable to create rundir",
+  "Unable to initialize libvirt",
+  "Unable to setup signal handlers",
+  "Unable to drop privileges",
+  "Unable to initialize network sockets",
+  "Unable to load configuration file",
+  "Unable to look for hook scripts");
+
+
+static int daemonForkIntoBackground(const char *argv0)
+{
+int statuspipe[2];
+if (pipe(statuspipe) < 0)
+return -1;
+
+int pid = fork();
+switch (pid) {
+case 0:
+{
+int stdinfd = -1;
+int stdoutfd = -1;
+int nextpid;
+
+VIR_FORCE_CLOSE(statuspipe[0]);
+
+if ((stdinfd = open("/dev/null", O_RDONLY)) < 0)
+goto cleanup;
+if ((stdoutfd = open("/dev/null", O_WRONLY)) < 0)
+goto cleanup;
+if (dup2(stdinfd, STDIN_FILENO) != STDIN_FILENO)
+goto cleanup;
+if (dup2(stdoutfd, STDOUT_FILENO) != STDOUT_FILENO)
+goto cleanup;
+if (dup2(stdoutfd, STDERR_FILENO) != STDERR_FILENO)
+goto cleanup;
+if (VIR_CLOSE(stdinfd) < 0)
+goto cleanup;
+if (VIR_CLOSE(stdoutfd) < 0)
+goto cleanup;
+
+if (setsid() < 0)
+goto cleanup;
+
+nextpid = fork();
+switch (nextpid) {
+case 0:
+return statuspipe[1];
+case -1:
+return -1;
+default:
+_exit(0);
+}
+
+cleanup:
+VIR_FORCE_CLOSE(stdoutfd);
+VIR_FORCE_CLOSE(stdinfd);
+return -1;
+
+}
+
+case -1:
+return -1;
+
+default:
+{
+int got, exitstatus = 0;
+int ret;
+char status;
+
+

[libvirt] [PATCH 1/8] Thread pool impl

2010-12-01 Thread Daniel P. Berrange
From: Hu Tao 

* src/util/threadpool.c, src/util/threadpool.h: Thread pool
  implementation
* src/Makefile.am: Build thread pool
---
 src/Makefile.am   |1 +
 src/util/threadpool.c |  178 +
 src/util/threadpool.h |   23 ++
 3 files changed, 202 insertions(+), 0 deletions(-)
 create mode 100644 src/util/threadpool.c
 create mode 100644 src/util/threadpool.h

diff --git a/src/Makefile.am b/src/Makefile.am
index a9a1986..d71c644 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -73,6 +73,7 @@ UTIL_SOURCES =
\
util/threads.c util/threads.h   \
util/threads-pthread.h  \
util/threads-win32.h\
+   util/threadpool.c util/threadpool.h \
util/uuid.c util/uuid.h \
util/util.c util/util.h \
util/xml.c util/xml.h   \
diff --git a/src/util/threadpool.c b/src/util/threadpool.c
new file mode 100644
index 000..cf998bf
--- /dev/null
+++ b/src/util/threadpool.c
@@ -0,0 +1,178 @@
+
+#include 
+
+#include "threadpool.h"
+#include "memory.h"
+#include "threads.h"
+#include "virterror_internal.h"
+
+#define VIR_FROM_THIS VIR_FROM_NONE
+
+typedef struct _virThreadPoolJob virThreadPoolJob;
+typedef virThreadPoolJob *virThreadPoolJobPtr;
+
+struct _virThreadPoolJob {
+virThreadPoolJobPtr next;
+
+void *data;
+};
+
+struct _virThreadPool {
+int quit;
+
+virThreadPoolJobFunc jobFunc;
+void *jobOpaque;
+virThreadPoolJobPtr jobList;
+
+virMutex mutex;
+virCond cond;
+virCond quit_cond;
+
+size_t maxWorkers;
+size_t freeWorkers;
+size_t nWorkers;
+virThreadPtr workers;
+};
+
+static void virThreadPoolWorker(void *opaque)
+{
+virThreadPoolPtr pool = opaque;
+
+virMutexLock(&pool->mutex);
+
+while (1) {
+while (!pool->quit &&
+   !pool->jobList) {
+pool->freeWorkers++;
+if (virCondWait(&pool->cond, &pool->mutex) < 0) {
+pool->freeWorkers--;
+break;
+}
+pool->freeWorkers--;
+}
+
+if (pool->quit)
+break;
+
+virThreadPoolJobPtr job = pool->jobList;
+pool->jobList = pool->jobList->next;
+job->next = NULL;
+
+virMutexUnlock(&pool->mutex);
+(pool->jobFunc)(job->data, pool->jobOpaque);
+VIR_FREE(job);
+virMutexLock(&pool->mutex);
+}
+
+pool->nWorkers--;
+if (pool->nWorkers == 0)
+virCondSignal(&pool->quit_cond);
+virMutexUnlock(&pool->mutex);
+}
+
+virThreadPoolPtr virThreadPoolNew(size_t minWorkers,
+  size_t maxWorkers,
+  virThreadPoolJobFunc func,
+  void *opaque)
+{
+virThreadPoolPtr pool;
+int i;
+
+if (VIR_ALLOC(pool) < 0) {
+virReportOOMError();
+return NULL;
+}
+
+pool->jobFunc = func;
+pool->jobOpaque = opaque;
+
+if (virMutexInit(&pool->mutex) < 0)
+goto error;
+if (virCondInit(&pool->cond) < 0)
+goto error;
+if (virCondInit(&pool->quit_cond) < 0)
+goto error;
+
+if (VIR_ALLOC_N(pool->workers, minWorkers) < 0)
+goto error;
+
+pool->maxWorkers = maxWorkers;
+for (i = 0; i < minWorkers; i++) {
+if (virThreadCreate(&pool->workers[i],
+true,
+virThreadPoolWorker,
+pool) < 0)
+goto error;
+pool->nWorkers++;
+}
+
+return pool;
+
+error:
+virThreadPoolFree(pool);
+return NULL;
+}
+
+void virThreadPoolFree(virThreadPoolPtr pool)
+{
+virMutexLock(&pool->mutex);
+pool->quit = 1;
+if (pool->nWorkers > 0) {
+virCondBroadcast(&pool->cond);
+if (virCondWait(&pool->quit_cond, &pool->mutex) < 0)
+{}
+}
+VIR_FREE(pool->workers);
+virMutexUnlock(&pool->mutex);
+VIR_FREE(pool);
+}
+
+int virThreadPoolSendJob(virThreadPoolPtr pool,
+ void *jobData)
+{
+virThreadPoolJobPtr job;
+virThreadPoolJobPtr tmp;
+
+virMutexLock(&pool->mutex);
+if (pool->quit)
+goto error;
+
+if (pool->freeWorkers == 0 &&
+pool->nWorkers < pool->maxWorkers) {
+if (VIR_EXPAND_N(pool->workers, pool->nWorkers, 1) < 0) {
+virReportOOMError();
+goto error;
+}
+
+if (virThreadCreate(&pool->workers[pool->nWorkers],
+true,
+virThreadPoolWorker,
+pool) < 0)
+goto error;
+pool->nWorkers++;
+}
+
+if (VIR_ALLOC(job) < 0) {
+virReportOOMError();
+goto erro

[libvirt] [PATCH 2/8] Fix memory leak in logging setup

2010-12-01 Thread Daniel P. Berrange
The logging setup requires const char * strings, but the
virLogSetFromEnv() strdup's the env variables, thus causing
a memory leak

* src/util/logging.c: Avoid strdup'ing env variables
---
 src/util/logging.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/util/logging.c b/src/util/logging.c
index d65dec0..83cc358 100644
--- a/src/util/logging.c
+++ b/src/util/logging.c
@@ -980,8 +980,8 @@ void virLogSetFromEnv(void) {
 virLogParseDefaultPriority(debugEnv);
 debugEnv = getenv("LIBVIRT_LOG_FILTERS");
 if (debugEnv && *debugEnv)
-virLogParseFilters(strdup(debugEnv));
+virLogParseFilters(debugEnv);
 debugEnv = getenv("LIBVIRT_LOG_OUTPUTS");
 if (debugEnv && *debugEnv)
-virLogParseOutputs(strdup(debugEnv));
+virLogParseOutputs(debugEnv);
 }
-- 
1.7.2.3

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


[libvirt] [PATCH 0/8] Early preview: Re-factoring XDR RPC code

2010-12-01 Thread Daniel P. Berrange
NB: This patch series isn't intended to be applied yet.

The current remote driver and libvirtd daemon have a horrible mix
of network I/O,  RPC dispatch and RPC handling functionality. It
it neccessary to introduce a new daemon to provide a lock manager
for VM disks. Doing so would effectively require cut+paste of a
large part of libvirtd code since there are no reusable APis in
it. Likewise for the client side.

To address this problem, this series is an attempt to produce a
reusable set of APIs for building RPC servers and clients. The
new APIs will handle all the networking/sockets functionality
and all the RPC dispatch/serialization/deserialization code.

This will enable libvirtd and the remote driver to be gutted,
so that they only contain the code for actually implementing
the RPC handlers. Thus a lock daemon + lock plugin can be
provided without any code duplication.

This will also make it far easier for us to introduce new
RPC programs, eg an administrative program to allow libvirtd
itself to be manipulated, say, to changing logging levels on
the fly, kill mis-behaving network client, etc, etc. It would
also make it practical to experiment with splitting libvirtd
up into smaller daemons each handling one area of functionality.
This would in turn make it practical to write useful SELinux
policy for confining libvirt daemons

This series is *far* from complete. The streams stuff is
completely missing in the new APis. I have also not yet gutted
libvirtd, only the remote driver. It is also not fully tested
for ABI wire compatibility with existing libvirtd, though I
believe it is correctly preserving ABI. 

The diffstat is slightly mis-leading because lots of code
remains to be deleted from daemon/libvirtd.c and
daemon/dispatch.c. None the less, it is expected that the
total lines will increase, but this wll be offset by the
improved code clarity and separation of functionality.

Daniel

 daemon/event.c|3 
 src/Makefile.am   |   90 +
 src/remote/remote_driver.c| 2530 ++
 src/rpc/virnetclient.c| 1237 ++
 src/rpc/virnetclient.h|   60 
 src/rpc/virnetclientprogram.c |  258 +++
 src/rpc/virnetclientprogram.h |   71 +
 src/rpc/virnetclientsaslcontext.c |  246 +++
 src/rpc/virnetclientsaslcontext.h |   66 
 src/rpc/virnetmessage.c   |  215 +++
 src/rpc/virnetmessage.h   |   31 
 src/rpc/virnetprotocol.c  |  108 +
 src/rpc/virnetprotocol.h  |   81 +
 src/rpc/virnetprotocol.x  |  162 ++
 src/rpc/virnetserver.c|  654 +
 src/rpc/virnetserver.h|   74 +
 src/rpc/virnetserverclient.c  |  974 ++
 src/rpc/virnetserverclient.h  |   40 
 src/rpc/virnetservermessage.h |   20 
 src/rpc/virnetserverprogram.c |  437 ++
 src/rpc/virnetserverprogram.h |   76 +
 src/rpc/virnetserverservice.c |  208 +++
 src/rpc/virnetserverservice.h |   32 
 src/rpc/virnetsocket.c|  715 ++
 src/rpc/virnetsocket.h|   97 +
 src/rpc/virnettlscontext.c|  611 +
 src/rpc/virnettlscontext.h|   63 
 src/util/logging.c|4 
 src/util/threadpool.c |  178 ++
 src/util/threadpool.h |   23 
 src/virtlockd.c   |  620 +
 31 files changed, 7866 insertions(+), 2118 deletions(-)


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


Re: [libvirt] [PATCH] qemu: Fix typo in qemuTeardownDiskPathDeny

2010-12-01 Thread Matthias Bolte
2010/12/1 Osier Yang :
> typo in error message, it should be by copy-a-paste
> from "qemuSetupDiskPathAllow".
>
> * src/qemu/qemu_driver.c (qemuTeardownDiskPathDeny)
> ---
>  src/qemu/qemu_driver.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index fcb90a3..5d90e59 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -3401,7 +3401,7 @@ static int qemuTeardownDiskPathDeny(virDomainDiskDefPtr 
> disk ATTRIBUTE_UNUSED,
>             VIR_DEBUG("Ignoring EACCES for %s", path);
>         } else {
>             virReportSystemError(-rc,
> -                                 _("Unable to allow access for disk path 
> %s"),
> +                                 _("Unable to deny access for disk path %s"),
>                                  path);
>             return -1;
>         }
> --
> 1.7.3.2
>

ACK, thanks, pushed :)

Matthias

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

Re: [libvirt] [PATCH 7/n] qemu: plug memory leak

2010-12-01 Thread Eric Blake
On 12/01/2010 09:44 AM, Matthias Bolte wrote:
> 2010/11/30 Eric Blake :
>> * src/qemu/qemu_driver.c (qemudShutdown): Free all strings and the
>> ebtables structure.
>> * src/libvirt_private.syms (ebtablesContextFree): Export missing
>> symbol.
>> * src/util/ebtables.c (ebtablesContextFree): Allow early exit.
>> ---
>>
>> This leak triggers on every start/stop of a qemu domain, although
>> it typically accounts for less than 1k leak per sequence.
>>
> 
>> VIR_FREE(qemu_driver->hugepage_path);
>>
>> +VIR_FREE(qemu_driver->securityDriverName);
> 
> Any specific reason for this empty line in this block of free calls?

Only because that was a place where the list of items being freed didn't
directly correspond to the declaration order within the struct, whereas
the earlier list had pretty much been done in the same order.  Not much
reason for either keeping or deleting it, since it's just cosmetic.  So
I deleted it. :)

> 
> ACK.

Thanks; I've pushed 6 and 7 now.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 6/n] libvirtd: avoid memory leak on shutdown

2010-12-01 Thread Matthias Bolte
2010/11/30 Eric Blake :
> * daemon/libvirtd.c (qemudRunLoop): Free any remaining client data.
> ---
>
> Since qemudCleanup calls VIR_FREE(server), it only makes sense to
> first free all of server's contents.
>
> Probably not the most important leak to plug (it only triggers at
> libvirtd exit, where the memory would be abandoned by process exit
> anyways, and does not affect clients that link against libvirt as
> a library), but plugging it makes leak analysis of the rest of
> libvirtd easier.
>
>  daemon/libvirtd.c |    4 
>  1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
> index caf51bf..791b3dc 100644
> --- a/daemon/libvirtd.c
> +++ b/daemon/libvirtd.c
> @@ -2403,6 +2403,10 @@ cleanup:
>         server->workers[i].hasThread = 0;
>     }
>     VIR_FREE(server->workers);
> +    for (i = 0; i < server->nclients; i++)
> +        qemudFreeClient(server->clients[i]);
> +    server->nclients = 0;
> +    VIR_SHRINK_N(server->clients, server->nclients_max, 
> server->nclients_max);
>
>     virMutexUnlock(&server->lock);
>     return NULL;
> --
> 1.7.3.2
>

ACK.

Matthias

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

Re: [libvirt] [PATCH 7/n] qemu: plug memory leak

2010-12-01 Thread Matthias Bolte
2010/11/30 Eric Blake :
> * src/qemu/qemu_driver.c (qemudShutdown): Free all strings and the
> ebtables structure.
> * src/libvirt_private.syms (ebtablesContextFree): Export missing
> symbol.
> * src/util/ebtables.c (ebtablesContextFree): Allow early exit.
> ---
>
> This leak triggers on every start/stop of a qemu domain, although
> it typically accounts for less than 1k leak per sequence.
>

> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index f00d8a3..faab42a 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -2068,10 +2068,9 @@ qemudShutdown(void) {
>
>     virSysinfoDefFree(qemu_driver->hostsysinfo);
>
> -    VIR_FREE(qemu_driver->securityDriverName);
> -    VIR_FREE(qemu_driver->logDir);
>     VIR_FREE(qemu_driver->configDir);
>     VIR_FREE(qemu_driver->autostartDir);
> +    VIR_FREE(qemu_driver->logDir);
>     VIR_FREE(qemu_driver->stateDir);
>     VIR_FREE(qemu_driver->libDir);
>     VIR_FREE(qemu_driver->cacheDir);
> @@ -2081,10 +2080,18 @@ qemudShutdown(void) {
>     VIR_FREE(qemu_driver->vncListen);
>     VIR_FREE(qemu_driver->vncPassword);
>     VIR_FREE(qemu_driver->vncSASLdir);
> -    VIR_FREE(qemu_driver->saveImageFormat);
> +    VIR_FREE(qemu_driver->spiceTLSx509certdir);
> +    VIR_FREE(qemu_driver->spiceListen);
> +    VIR_FREE(qemu_driver->spicePassword);
>     VIR_FREE(qemu_driver->hugetlbfs_mount);
>     VIR_FREE(qemu_driver->hugepage_path);
>
> +    VIR_FREE(qemu_driver->securityDriverName);

Any specific reason for this empty line in this block of free calls?

> +    VIR_FREE(qemu_driver->saveImageFormat);
> +    VIR_FREE(qemu_driver->dumpImageFormat);
> +
> +    ebtablesContextFree(qemu_driver->ebtables);
> +
>     if (qemu_driver->cgroupDeviceACL) {
>         for (i = 0 ; qemu_driver->cgroupDeviceACL[i] != NULL ; i++)
>             VIR_FREE(qemu_driver->cgroupDeviceACL[i]);

ACK.

Matthias

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

Re: [libvirt] Release of libvirt 0.8.6

2010-12-01 Thread Matthias Bolte
2010/12/1 Diego Elio Pettenò :
> Il giorno mar, 30/11/2010 alle 21.09 +0100, Daniel Veillard ha scritto:
>>
>>   As indicated 10 days ago, today was time for a release, I didn't
>> had much time so I simply generated a release from libvirt git
>> without much testing. Hopefully this will be okay !
>
> Doesn't seem to be the case :/
>
> In file included from qemu/qemu_conf.c:42:0:
> qemu/qemu_conf.h:243:47: warning: 'enum virVMOperationType' declared
> inside parameter list
> qemu/qemu_conf.h:323:32: warning: 'enum virVMOperationType' declared
> inside parameter list
> qemu/qemu_conf.c:1646:28: warning: 'enum virVMOperationType' declared
> inside parameter list
> qemu/qemu_conf.c:1646:47: error: parameter 6 ('vmop') has incomplete
> type
> qemu/qemu_conf.c: In function 'qemudPhysIfaceConnect':
> qemu/qemu_conf.c:1646:47: warning: unused parameter
> 'vmop' [-Wunused-parameter]
> qemu/qemu_conf.c: At top level:
> qemu/qemu_conf.c:3959:32: warning: 'enum virVMOperationType' declared
> inside parameter list
> qemu/qemu_conf.c:3959:51: error: parameter 13 ('vmop') has incomplete
> type
> qemu/qemu_conf.c: In function 'qemudBuildCommandLine':
> qemu/qemu_conf.c:4803:51: error: type of formal parameter 6 is
> incomplete
> qemu/qemu_conf.c:3959:51: warning: unused parameter
> 'vmop' [-Wunused-parameter]
> make[3]: *** [libvirt_driver_qemu_la-qemu_conf.lo] Error 1
> make[3]: *** Waiting for unfinished jobs
>
> I'll see if I can track this down later… I guess it might be related to
> Jean-Baptiste post “Fix warning when macvtap support is disabled”,
> especially since I see macvtap references when macvtap is disabled at
> configure time.
>

This two commits in git:

Fix undefined symbol errors when macvtap support is disabled
474b1c1487828a17fe9e1025901334d9820ea350

Fix warning when macvtap support is disabled
45147ca37f3d93ea67b02a6c0e435bdf40b4ddc5

should fix the errors you listed above.

Matthias

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

Re: [libvirt] [PATCH] virsh: update help for "virsh help help"

2010-12-01 Thread Eric Blake
On 12/01/2010 09:04 AM, Justin Clift wrote:
> On 01/12/2010, at 11:24 PM, Osier Yang wrote:
>> As virsh help supports both command and command group now,
>> update "cmdHelp" to print consite help, (this patch is
>> increment of "7829052757953023b0826e0293ffe18ed4ab89e9").
>>
>> And also remove redundant empty line in "vshUsage".
>>
>> * tools/virsh.c
>> ---
>> tools/virsh.c |   19 +--
>> 1 files changed, 13 insertions(+), 6 deletions(-)
> 
> ACK for this, but you'll need to drop the fix for the extra carriage return 
> in the --help output.

That resolved automatically by 'git am -3', so I've pushed the resulting
modified patch.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] Fix undefined symbol error when macvtap support is disabled

2010-12-01 Thread Matthias Bolte
2010/12/1 Eric Blake :
> On 12/01/2010 08:34 AM, Matthias Bolte wrote:
>> Use macvtap specific functions depending on WITH_MACVTAP.
>>
>> Use #if instead of #ifdef to check for WITH_MACVTAP, because
>> WITH_MACVTAP is always defined with value 0 or 1.
>
> That, and #if undefined behaves the same as #if defined_as_0.
>
>>
>> Also export virVMOperationType{To|From}String unconditional,
>> because they are used unconditional in the domain config code.
>> ---
>>  src/libvirt_macvtap.syms |    5 +++--
>>  src/libvirt_private.syms |    5 +
>>  src/qemu/qemu_driver.c   |    4 
>>  src/util/macvtap.h       |   19 +--
>>  4 files changed, 21 insertions(+), 12 deletions(-)
>
> ACK.
>
>> +++ b/src/qemu/qemu_driver.c
>> @@ -11879,6 +11879,7 @@ cleanup:
>>      return ret;
>>  }
>>
>> +#if WITH_MACVTAP
>>  static void
>>  qemudVPAssociatePortProfiles(virDomainDefPtr def) {
>>      int i;
>> @@ -11913,6 +11914,7 @@ err_exit:
>>          }
>>      }
>>  }
>> +#endif /* WITH_MACVTAP */
>
> I would have done:
>
> #else /* !WITH_MACVTAP */
> # define qemudVPAssociatePortProfiles(ignored) /* */
> #endif
>

Okay, I folded this in before pushing as discussed on IRC:

#else /* !WITH_MACVTAP */
static void
qemudVPAssociatePortProfiles(virDomainDefPtr def ATTRIBUTE_UNUSED) { }
#endif

Matthias

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

Re: [libvirt] [PATCH] Fix flaw in thread creation APIs

2010-12-01 Thread Eric Blake
On 12/01/2010 04:25 AM, Daniel P. Berrange wrote:
> The arguments passed to the thread function must be allocated on
> the heap, rather than the stack, since it is possible for the
> spawning thread to continue before the new thread runs at all.
> In such a case, it is possible that the area of stack where the
> thread args were stored is overwritten.
> 
> * src/util/threads-pthread.c, src/util/threads-win32.c: Allocate
>   thread arguments on the heap
> ---
>  src/util/threads-pthread.c |   15 +--
>  src/util/threads-win32.c   |   17 ++---
>  2 files changed, 27 insertions(+), 5 deletions(-)

ACK.  I'm surprised we haven't noticed it sooner.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] make syntax-check -> make: *** [sc_check_author_list] Error 1 on libvirt-0.8.5

2010-12-01 Thread Eric Blake
On 12/01/2010 04:14 AM, Justin Clift wrote:
> On 01/12/2010, at 9:03 PM, Kenneth Nagin wrote:
>> I am receiving syntax error when compiling libvirt-0.8.5.
>> However, make without syntax-check completes successfully.
> 
> Interesting.  There was a problem with make syntax-check that was patched last
> night, after the 0.8.6 release.

Yes, but it was a different check that was failing, and the patch for
that fix won't solve the too-old git failing the authors check.

> If you can, and the error still crops up, then it's a new one we need to look 
> at.
> Otherwise it's already been fixed in the source, your choice of which source
> tarball version you want to then use. :)

And ultimately, failure of 'make syntax-check' is non-fatal; it is not a
prerequisite for building working binaries, so much as a way to try and
enforce consistent style within the code base.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] virsh: update help for "virsh help help"

2010-12-01 Thread Justin Clift
On 01/12/2010, at 11:24 PM, Osier Yang wrote:
> As virsh help supports both command and command group now,
> update "cmdHelp" to print consite help, (this patch is
> increment of "7829052757953023b0826e0293ffe18ed4ab89e9").
> 
> And also remove redundant empty line in "vshUsage".
> 
> * tools/virsh.c
> ---
> tools/virsh.c |   19 +--
> 1 files changed, 13 insertions(+), 6 deletions(-)

ACK for this, but you'll need to drop the fix for the extra carriage return in 
the --help output.

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


Re: [libvirt] make syntax-check -> make: *** [sc_check_author_list] Error 1 on libvirt-0.8.5

2010-12-01 Thread Eric Blake
On 12/01/2010 03:03 AM, Kenneth Nagin wrote:
> 
> I am receiving syntax error when compiling libvirt-0.8.5.
> However, make without syntax-check completes successfully.
> 
> check_author_list
> %aE
> maint.mk: committer(s) not listed in AUTHORS

That means your version of git is too old to support the specific log
formatting directive that we are using.  What version of git are you
using, and is it worth us fixing that syntax check to skip if git is too
old?

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] Fix undefined symbol error when macvtap support is disabled

2010-12-01 Thread Eric Blake
On 12/01/2010 08:34 AM, Matthias Bolte wrote:
> Use macvtap specific functions depending on WITH_MACVTAP.
> 
> Use #if instead of #ifdef to check for WITH_MACVTAP, because
> WITH_MACVTAP is always defined with value 0 or 1.

That, and #if undefined behaves the same as #if defined_as_0.

> 
> Also export virVMOperationType{To|From}String unconditional,
> because they are used unconditional in the domain config code.
> ---
>  src/libvirt_macvtap.syms |5 +++--
>  src/libvirt_private.syms |5 +
>  src/qemu/qemu_driver.c   |4 
>  src/util/macvtap.h   |   19 +--
>  4 files changed, 21 insertions(+), 12 deletions(-)

ACK.

> +++ b/src/qemu/qemu_driver.c
> @@ -11879,6 +11879,7 @@ cleanup:
>  return ret;
>  }
>  
> +#if WITH_MACVTAP
>  static void
>  qemudVPAssociatePortProfiles(virDomainDefPtr def) {
>  int i;
> @@ -11913,6 +11914,7 @@ err_exit:
>  }
>  }
>  }
> +#endif /* WITH_MACVTAP */

I would have done:

#else /* !WITH_MACVTAP */
# define qemudVPAssociatePortProfiles(ignored) /* */
#endif

>  
>  /* Finish is the third and final step, and it runs on the destination host. 
> */
>  static virDomainPtr
> @@ -11974,7 +11976,9 @@ qemudDomainMigrateFinish2 (virConnectPtr dconn,
>  goto cleanup;
>  }
>  
> +#if WITH_MACVTAP
>  qemudVPAssociatePortProfiles(vm->def);
> +#endif /* WITH_MACVTAP */

in order to avoid an in-function #ifdef. Up to you if you want to tweak
that before pushing.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] Release of libvirt 0.8.6

2010-12-01 Thread Justin Clift
On 02/12/2010, at 2:26 AM, Diego Elio Pettenò wrote:
> Il giorno mar, 30/11/2010 alle 21.09 +0100, Daniel Veillard ha scritto:
>> 
>>  As indicated 10 days ago, today was time for a release, I didn't
>> had much time so I simply generated a release from libvirt git
>> without much testing. Hopefully this will be okay ! 
> 
> Doesn't seem to be the case :/

Ouch, that's two releases in a row with problems showing up straight away after 
release.

Looks like it might be time to put some kind of regression testing in place, as 
a go/no-go release criteria.

Our adhoc approach isn't working well enough any more.



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


Re: [libvirt] [RFC] new preferences requirement

2010-12-01 Thread Osier Yang

于 2010年12月01日 18:26, Daniel P. Berrange 写道:

On Wed, Dec 01, 2010 at 05:35:38PM +0800, Osier Yang wrote:

Hi, all

We have some new requirements of preferences, I listed
which of them I known, and think is useful as follows:

1) for the path of x509 certificate and keys of client

The path of x509 certificate and keys of client is hard
coded in remote driver. e.g.

/* 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"


We can't assume one set of certs/keys is suitable for all
URIs, so making this a preference setting doesn't help. There
needs to be a parameter in the URI to specify a cert/key name
to override the defaults on a per-connection basis



yeah, reasonable, I didn't consider all of the drivers, will fix
this problem with adding parameters for URI.


2) for default default driver and subdriver for disk image

Another requirement of new preference is default driver and subdriver
for disk images, currently we use "phy" for "driver" in virsh, and
"raw" for "subdriver" in qemu driver by default if user doesn't specify
them, it causes bugs, though we could say to user "you should use
options --driver and --subdriver", but these two options are optional.

IMHO, the best solution for those bugs is to provide new preferences.


virsh is broken here. It shouldn't be setting the driver if the
user doesn't specify it. The libvirt hypervisor specific drivers
know the correct defaults if omitted, so virsh shouldn't try to
guess this (wrongly) itself.



will fix it.


3) for default NIC and storage type

"Chris Phillips" raised up the requirement not long ago:

http://www.redhat.com/archives/libvirt-users/2010-November/msg00033.html


This doesn't belong in libvirt. See my reply in that thread.




Should we add these new preferences(if they are really neccessary)
in qemu.conf? or create new config file, e.g. The approch Justin
raised up an approch before:
http://www.redhat.com/archives/libvir-list/2010-November/msg00651.html

Though for Justin's approch, IMHO we'd better also to provide a
default config file, e.g. "/etc/libvirt/client.conf".


Library APIs like libvirt shouldn't really rely on preference files,
because such a file would silently change behaviour in ways that
applications using the API may not expect. ie the preference
may work nicely for one app/user of libvirt, but not for another
app. Environment variables would cause similar problems too. Anything
that needs to be configured should be configurable via the APIs or
XML.



good to known, thanks :-)

- Osier

Regards,
Daniel


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

Re: [libvirt] Link error since commit c2b3827

2010-12-01 Thread Matthias Bolte
2010/12/1 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.
>

I posted a patch for this problem:

https://www.redhat.com/archives/libvir-list/2010-December/msg00034.html

Matthias

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

Re: [libvirt] Best virsh group for storage "find-*" commands?

2010-12-01 Thread Osier Yang

于 2010年12月01日 21:17, Justin Clift 写道:

Hi us,

Just realised the new groupings of commands in virsh help has
the two storage "find" commands in domain management.

These ones:

   + find-storage-pool-sources-as   find potential storage pool sources
   + find-storage-pool-sources  discover potential storage pool sources

They'd be better placed in the Storage Pool group wouldn't they?


yeah, right, not reasonble to put them in "Domain Management", they
have no relationship with each other, it's by my mistake. will resolve
it.

- Osier

Regards and best wishes,

Justin Clift

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


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

[libvirt] [PATCH] Fix undefined symbol error when macvtap support is disabled

2010-12-01 Thread Matthias Bolte
Use macvtap specific functions depending on WITH_MACVTAP.

Use #if instead of #ifdef to check for WITH_MACVTAP, because
WITH_MACVTAP is always defined with value 0 or 1.

Also export virVMOperationType{To|From}String unconditional,
because they are used unconditional in the domain config code.
---
 src/libvirt_macvtap.syms |5 +++--
 src/libvirt_private.syms |5 +
 src/qemu/qemu_driver.c   |4 
 src/util/macvtap.h   |   19 +--
 4 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/src/libvirt_macvtap.syms b/src/libvirt_macvtap.syms
index 107b7da..b48565b 100644
--- a/src/libvirt_macvtap.syms
+++ b/src/libvirt_macvtap.syms
@@ -1,9 +1,10 @@
 #
+# These symbols are dependent on WITH_MACVTAP.
+#
+
 
 # macvtap.h
 delMacvtap;
 openMacvtapTap;
-virVMOperationTypeFromString;
-virVMOperationTypeToString;
 vpAssociatePortProfileId;
 vpDisassociatePortProfileId;
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 310d8f4..3c1c823 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -504,6 +504,11 @@ virLogStartup;
 virLogUnlock;
 
 
+# macvtap.h
+virVMOperationTypeFromString;
+virVMOperationTypeToString;
+
+
 # memory.h
 virAlloc;
 virAllocN;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index fcb90a3..aa3478f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11879,6 +11879,7 @@ cleanup:
 return ret;
 }
 
+#if WITH_MACVTAP
 static void
 qemudVPAssociatePortProfiles(virDomainDefPtr def) {
 int i;
@@ -11913,6 +11914,7 @@ err_exit:
 }
 }
 }
+#endif /* WITH_MACVTAP */
 
 /* Finish is the third and final step, and it runs on the destination host. */
 static virDomainPtr
@@ -11974,7 +11976,9 @@ qemudDomainMigrateFinish2 (virConnectPtr dconn,
 goto cleanup;
 }
 
+#if WITH_MACVTAP
 qemudVPAssociatePortProfiles(vm->def);
+#endif /* WITH_MACVTAP */
 
 if (flags & VIR_MIGRATE_PERSIST_DEST) {
 if (vm->persistent)
diff --git a/src/util/macvtap.h b/src/util/macvtap.h
index 389d1fd..3ae2c24 100644
--- a/src/util/macvtap.h
+++ b/src/util/macvtap.h
@@ -57,11 +57,6 @@ struct _virVirtualPortProfileParams {
 } u;
 };
 
-
-# if defined(WITH_MACVTAP)
-
-#  include "internal.h"
-
 enum virVMOperationType {
 VIR_VM_OP_CREATE,
 VIR_VM_OP_SAVE,
@@ -75,6 +70,10 @@ enum virVMOperationType {
 VIR_VM_OP_LAST
 };
 
+# if WITH_MACVTAP
+
+#  include "internal.h"
+
 int openMacvtapTap(const char *ifname,
const unsigned char *macaddress,
const char *linkdev,
@@ -90,11 +89,9 @@ void delMacvtap(const char *ifname,
 const char *linkdev,
 virVirtualPortProfileParamsPtr virtPortProfile);
 
-# endif /* WITH_MACVTAP */
-
-# define MACVTAP_MODE_PRIVATE_STR  "private"
-# define MACVTAP_MODE_VEPA_STR "vepa"
-# define MACVTAP_MODE_BRIDGE_STR   "bridge"
+#  define MACVTAP_MODE_PRIVATE_STR  "private"
+#  define MACVTAP_MODE_VEPA_STR "vepa"
+#  define MACVTAP_MODE_BRIDGE_STR   "bridge"
 
 int vpAssociatePortProfileId(const char *macvtap_ifname,
  const unsigned char *macvtap_macaddr,
@@ -109,6 +106,8 @@ int vpDisassociatePortProfileId(const char *macvtap_ifname,
 const virVirtualPortProfileParamsPtr virtPort,
 enum virVMOperationType vmOp);
 
+# endif /* WITH_MACVTAP */
+
 VIR_ENUM_DECL(virVirtualPort)
 VIR_ENUM_DECL(virVMOperation)
 
-- 
1.7.0.4

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


Re: [libvirt] CGROUPS network classID setting in domain

2010-12-01 Thread D. Herrendoerfer

Hi,

I went ahead and added what was needed to work the network
controller - that was easy.

The basic way it works is beautifully simple - if there is a cgroup
net_cls controller, then the qemu_driver will initialize it and add
a default classid.

With this approach modelling traffic is relatively easy across
more than one interface, but restricted when several VMs communicate
over one interface.

The changes I made so far don't require changes to domain xml, and they
will only work on linux hosts with cgroups enabled.

If there are no objections to the design itself I'd post the patches  
soon.


Regards,

Dirk

On Nov 22, 2010, at 8:23 PM, D. Herrendoerfer wrote:



On Nov 22, 2010, at 2:21 PM, Daniel P. Berrange wrote:


On Thu, Nov 18, 2010 at 04:22:49PM +0100, D. Herrendoerfer wrote:

Hello,

I'm looking into the possibility of putting a network(tc) classID  
into

to the domain description and adding it into a (possibly) mounted
cgroup directory upon launch of a VM.

Has anyone before looked into this ?
I've seen this mentioned in an abstract by Daniel B.

I imagine a classid entry to look somewhat like:


 foo
3e3fce45-4f53-4fa7-bb32-11f34168b82b 
...
0x1234

...

Thoughts ?


This isn't a very nice approach to modelling network controls
for a guest. The use of 'tc' for controlling networking is
a Linux specific implementation detail, that is not at all
applicable to any other platform. A bare classid on its own
also has zero semantic value - this is akin to configuring
guest disks by using an inode number in the XML instead of
the file path.



Agreed, but ..


Any networking controls really need a higher level XML
description of the conceptual policy that is being applied
to the network traffic, that is independant of any single
implementation mechanism. Internally libvirt would create
TC classids itself per VM, and map those to cgroups.



.. I don't really want to use libvirt for a "one-shot" configuration
of the network policy, but rather manage a group of classid
settings and simply have the ability to classify a VM to a group.
This management is specific to a host, not a single VM.
Therefore it would be a great benefit if libvirt would simply
set a classid for a running VM, and let the network admin tool
figure out the traffic shaping.



Regards,
Daniel


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


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


Re: [libvirt] [PATCH] qemud: fix memory leak in io error events

2010-12-01 Thread Daniel P. Berrange
On Wed, Dec 01, 2010 at 09:29:31AM -0600, Anthony Liguori wrote:
> The extra data isn't being free()'d for IO error events that have a reason.
> 
> Signed-off-by: Anthony Liguori 
> ---
> I wasn't able to test this because the build is broken for me.  I won't be 
> able
> to test it in the field for a couple days.
> 
> The problem we're seeing is a rather fast memory leak that exhausts all system
> memory.  I believe the source of the leak is that our underlying storage is
> throwing an I/O error and libvirt is not properly freeing the resulting IO
> error event object.
> 
> Because the storage is constantly generating errors and the guest is 
> constantly
> reading, memory is just consumed until the system is exhausted.
> 
> diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
> index e88aafe..5f086bd 100644
> --- a/src/conf/domain_event.c
> +++ b/src/conf/domain_event.c
> @@ -472,6 +472,7 @@ void virDomainEventFree(virDomainEventPtr event)
>  return;
>  
>  switch (event->eventID) {
> +case VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON:
>  case VIR_DOMAIN_EVENT_ID_IO_ERROR:
>  VIR_FREE(event->data.ioError.srcPath);
>  VIR_FREE(event->data.ioError.devAlias);

ACK

Daniel

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


[libvirt] [PATCH] qemud: fix memory leak in io error events

2010-12-01 Thread Anthony Liguori
The extra data isn't being free()'d for IO error events that have a reason.

Signed-off-by: Anthony Liguori 
---
I wasn't able to test this because the build is broken for me.  I won't be able
to test it in the field for a couple days.

The problem we're seeing is a rather fast memory leak that exhausts all system
memory.  I believe the source of the leak is that our underlying storage is
throwing an I/O error and libvirt is not properly freeing the resulting IO
error event object.

Because the storage is constantly generating errors and the guest is constantly
reading, memory is just consumed until the system is exhausted.

diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index e88aafe..5f086bd 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -472,6 +472,7 @@ void virDomainEventFree(virDomainEventPtr event)
 return;
 
 switch (event->eventID) {
+case VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON:
 case VIR_DOMAIN_EVENT_ID_IO_ERROR:
 VIR_FREE(event->data.ioError.srcPath);
 VIR_FREE(event->data.ioError.devAlias);
-- 
1.7.0.4

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


Re: [libvirt] Release of libvirt 0.8.6

2010-12-01 Thread Diego Elio Pettenò
Il giorno mar, 30/11/2010 alle 21.09 +0100, Daniel Veillard ha scritto:
> 
>   As indicated 10 days ago, today was time for a release, I didn't
> had much time so I simply generated a release from libvirt git
> without much testing. Hopefully this will be okay ! 

Doesn't seem to be the case :/

In file included from qemu/qemu_conf.c:42:0:
qemu/qemu_conf.h:243:47: warning: 'enum virVMOperationType' declared
inside parameter list
qemu/qemu_conf.h:323:32: warning: 'enum virVMOperationType' declared
inside parameter list
qemu/qemu_conf.c:1646:28: warning: 'enum virVMOperationType' declared
inside parameter list
qemu/qemu_conf.c:1646:47: error: parameter 6 ('vmop') has incomplete
type
qemu/qemu_conf.c: In function 'qemudPhysIfaceConnect':
qemu/qemu_conf.c:1646:47: warning: unused parameter
'vmop' [-Wunused-parameter]
qemu/qemu_conf.c: At top level:
qemu/qemu_conf.c:3959:32: warning: 'enum virVMOperationType' declared
inside parameter list
qemu/qemu_conf.c:3959:51: error: parameter 13 ('vmop') has incomplete
type
qemu/qemu_conf.c: In function 'qemudBuildCommandLine':
qemu/qemu_conf.c:4803:51: error: type of formal parameter 6 is
incomplete
qemu/qemu_conf.c:3959:51: warning: unused parameter
'vmop' [-Wunused-parameter]
make[3]: *** [libvirt_driver_qemu_la-qemu_conf.lo] Error 1
make[3]: *** Waiting for unfinished jobs

I'll see if I can track this down later… I guess it might be related to
Jean-Baptiste post “Fix warning when macvtap support is disabled”,
especially since I see macvtap references when macvtap is disabled at
configure time.

-- 
Diego Elio Pettenò — “Flameeyes”
http://blog.flameeyes.eu/

If you found a .asc file in this mail and know not what it is,
it's a GnuPG digital signature: http://www.gnupg.org/


signature.asc
Description: This is a digitally signed message part
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 1/2] tests: Support for faking emulator in qemuxml2argv

2010-12-01 Thread Jiri Denemark
This patch allows for using custom scripts instead of /usr/bin/qemu
emulator in domain XML. To do so, one would specify relative path to the
custom script in . The path needs to be relative to
qemuxml2argvdata directory and it will be transparently made absolute in
runtime. The expected command line needs to contain the exact relative
path as was used in domain XML.

The problem is RelaxNG schema for domain XML only allows for absolute
path within . To workaround it, an extra '/' must be added at
the beginning of the path. That is, instead of "./qemu.sh" or
"../emulator/qemu.sh" one would use "/./qemu.sh" or
"/../emulator/qemu.sh". The extra slash is removed before further
processing. I don't like this workaround, it's very ugly but it's the
best option I was able to come up with. Relaxing domain XML schema is
not an option IMO.
---
 tests/qemuxml2argvtest.c |   18 ++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index e6174be..dd07001 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -41,6 +41,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
 virDomainChrDef monitor_chr;
 virConnectPtr conn;
 char *log = NULL;
+char *emulator = NULL;
 
 if (!(conn = virGetConnect()))
 goto fail;
@@ -52,6 +53,16 @@ static int testCompareXMLToArgvFiles(const char *xml,
 VIR_DOMAIN_XML_INACTIVE)))
 goto fail;
 
+if (vmdef->emulator && STRPREFIX(vmdef->emulator, "/.")) {
+if (!(emulator = strdup(vmdef->emulator + 1)))
+goto fail;
+free(vmdef->emulator);
+vmdef->emulator = NULL;
+if (virAsprintf(&vmdef->emulator, "%s/qemuxml2argvdata/%s",
+abs_srcdir, emulator) < 0)
+goto fail;
+}
+
 if (extraFlags & QEMUD_CMD_FLAG_DOMID)
 vmdef->id = 6;
 else
@@ -104,6 +115,12 @@ static int testCompareXMLToArgvFiles(const char *xml,
 virResetLastError();
 }
 
+if (emulator && *argv) {
+free(*(char**) argv);
+*argv = emulator;
+emulator = NULL;
+}
+
 len = 1; /* for trailing newline */
 tmp = qenv;
 while (*tmp) {
@@ -144,6 +161,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
 
  fail:
 free(log);
+free(emulator);
 free(actualargv);
 if (argv) {
 tmp = argv;
-- 
1.7.3.2

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


[libvirt] [PATCH 2/2] tests: Add tests for CPU selection in qemu driver

2010-12-01 Thread Jiri Denemark
---
 tests/qemuxml2argvdata/qemu.sh |   64 
 .../qemuxml2argvdata/qemuxml2argv-cpu-exact1.args  |1 +
 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.xml |   28 +
 .../qemuxml2argvdata/qemuxml2argv-cpu-exact2.args  |1 +
 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml |   35 +++
 .../qemuxml2argv-cpu-minimum1.args |1 +
 .../qemuxml2argvdata/qemuxml2argv-cpu-minimum1.xml |   21 +++
 .../qemuxml2argv-cpu-minimum2.args |1 +
 .../qemuxml2argvdata/qemuxml2argv-cpu-minimum2.xml |   25 
 .../qemuxml2argvdata/qemuxml2argv-cpu-strict1.args |1 +
 .../qemuxml2argvdata/qemuxml2argv-cpu-strict1.xml  |   38 
 .../qemuxml2argv-cpu-topology1.args|1 +
 .../qemuxml2argv-cpu-topology1.xml |   21 +++
 .../qemuxml2argv-cpu-topology2.args|1 +
 .../qemuxml2argv-cpu-topology2.xml |   22 +++
 .../qemuxml2argv-cpu-topology3.args|1 +
 .../qemuxml2argv-cpu-topology3.xml |   21 +++
 tests/qemuxml2argvtest.c   |   20 ++
 18 files changed, 303 insertions(+), 0 deletions(-)
 create mode 100755 tests/qemuxml2argvdata/qemu.sh
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.xml

diff --git a/tests/qemuxml2argvdata/qemu.sh b/tests/qemuxml2argvdata/qemu.sh
new file mode 100755
index 000..6d5d354
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemu.sh
@@ -0,0 +1,64 @@
+#! /bin/sh
+
+candidates="/usr/bin/qemu-kvm
+/usr/libexec/qemu-kvm
+/usr/bin/qemu-system-x86_64
+/usr/bin/qemu"
+qemu=
+for candidate in $candidates; do
+if test -x $candidate; then
+qemu=$candidate
+break
+fi
+done
+
+real_qemu()
+{
+if test x$qemu != x; then
+exec $qemu "$@"
+else
+return 1
+fi
+}
+
+faked_machine()
+{
+echo "pc"
+}
+
+faked_cpu()
+{
+cat <
+  QEMUGuest1
+  c7a5fdbd-edaf-9455-926a-d65c16db1809
+  219200
+  219200
+  6
+  
+hvm
+
+  
+  
+qemu64
+
+
+
+
+
+
+
+  
+  
+  destroy
+  restart
+  destroy
+  
+  /./qemu.sh
+  
+
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.args 
b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.args
new file mode 100644
index 000..637f2e1
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc 
-cpu core2duo,+lahf_lm,+3dnowext,+xtpr,+ds_cpl,+tm,+ht,+ds,-nx -m 214 -smp 6 
-nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -net 
none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml
new file mode 100644
index 000..cd2a506
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml
@@ -0,0 +1,35 @@
+
+  QEMUGuest1
+  c7a5fdbd-edaf-9455-926a-d65c16db1809
+  219200
+  219200
+  6
+  
+hvm
+
+  
+  
+core2duo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  
+  
+  destroy
+  restart
+  destroy
+  
+  /./qemu.sh
+  
+
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.args 
b/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.args
new file mode 100644
index 000..80940f8
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test ./qemu.sh -S -M pc 
-cpu 
core2duo,+lahf_lm,+xtpr,+cx16,+tm2,+est,+vmx,+ds_cpl,+pbe,+tm,+ht,+ss,+acpi,+ds 
-m 214 -smp 6 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi 
-boot n -net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-mi

[libvirt] [PATCH 0/2] Add tests for CPU selection in qemu driver

2010-12-01 Thread Jiri Denemark
Some more CPU tests that can make use of recently introduced cpuMapOverride().

Jiri Denemark (2):
  tests: Support for faking emulator in qemuxml2argv
  tests: Add tests for CPU selection in qemu driver

 tests/qemuxml2argvdata/qemu.sh |   64 
 .../qemuxml2argvdata/qemuxml2argv-cpu-exact1.args  |1 +
 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.xml |   28 +
 .../qemuxml2argvdata/qemuxml2argv-cpu-exact2.args  |1 +
 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml |   35 +++
 .../qemuxml2argv-cpu-minimum1.args |1 +
 .../qemuxml2argvdata/qemuxml2argv-cpu-minimum1.xml |   21 +++
 .../qemuxml2argv-cpu-minimum2.args |1 +
 .../qemuxml2argvdata/qemuxml2argv-cpu-minimum2.xml |   25 
 .../qemuxml2argvdata/qemuxml2argv-cpu-strict1.args |1 +
 .../qemuxml2argvdata/qemuxml2argv-cpu-strict1.xml  |   38 
 .../qemuxml2argv-cpu-topology1.args|1 +
 .../qemuxml2argv-cpu-topology1.xml |   21 +++
 .../qemuxml2argv-cpu-topology2.args|1 +
 .../qemuxml2argv-cpu-topology2.xml |   22 +++
 .../qemuxml2argv-cpu-topology3.args|1 +
 .../qemuxml2argv-cpu-topology3.xml |   21 +++
 tests/qemuxml2argvtest.c   |   38 
 18 files changed, 321 insertions(+), 0 deletions(-)
 create mode 100755 tests/qemuxml2argvdata/qemu.sh
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.xml

-- 
1.7.3.2

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


[libvirt] [PATCH] schemas: Fix cpu element schema

2010-12-01 Thread Jiri Denemark
Both vendor and topology elements are optional.
---
 docs/schemas/domain.rng |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index fb44335..08ebefb 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -1745,6 +1745,8 @@
 
 
   
+
+
   
 
 
-- 
1.7.3.2

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


Re: [libvirt] Best virsh group for storage "find-*" commands?

2010-12-01 Thread Dave Allan
On Thu, Dec 02, 2010 at 12:17:04AM +1100, Justin Clift wrote:
> Hi us,
> 
> Just realised the new groupings of commands in virsh help has
> the two storage "find" commands in domain management.
> 
> These ones:
> 
>   + find-storage-pool-sources-as   find potential storage pool sources
>   + find-storage-pool-sources  discover potential storage pool sources
> 
> They'd be better placed in the Storage Pool group wouldn't they?

Yes.

Dave

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


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

2010-12-01 Thread Matthias Bolte
2010/12/1 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
>

ACK and pushed, thanks.

Matthias

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

Re: [libvirt] [PATCH] virsh: remove a badly placed line break in virsh -h output

2010-12-01 Thread Justin Clift
On 02/12/2010, at 12:42 AM, Osier Yang wrote:
>>> tools/virsh.c |2 +-
>>> 1 files changed, 1 insertions(+), 1 deletions(-)
>> 
>> Pushed this under the trivial rule.
>> 
> ah, I just sent patch with fix of this problem before, :-)
> 
> http://www.redhat.com/archives/libvir-list/2010-December/msg00012.html

Heh, yeah, just saw that.  Sorry. :/

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


Re: [libvirt] [RFC] new preferences requirement

2010-12-01 Thread Justin Clift
On 02/12/2010, at 12:46 AM, Daniel P. Berrange wrote:
> On Wed, Dec 01, 2010 at 09:19:30PM +1100, Justin Clift wrote:
>> On 01/12/2010, at 8:35 PM, Osier Yang wrote:
>>>  Should we add these new preferences(if they are really neccessary)
>>> in qemu.conf? or create new config file, e.g. The approch Justin
>>> raised up an approch before:
>>> http://www.redhat.com/archives/libvir-list/2010-November/msg00651.html
>>> 
>>>  Though for Justin's approch, IMHO we'd better also to provide a
>>> default config file, e.g. "/etc/libvirt/client.conf".
>>> 
>>>  Any feedback is welcomed, thanks
>> 
>> When thinking about this more, three levels of preference can be found in
>> other applications, and _might_ be the right approach for us to take as well.
> 
> Management of preferences belongs in application code, rather than
> libvirt. Library APIs need to have standard, predictable behaviour
> that apps can rely on in any deployment. We don't want that being
> changed globally for all applications by config files.
> 
> Even if apps do want configuration data, we can't assume they want the
> data stored in configuration files. Any current GTK application will
> use GConf for any configuration, or in the future GSettings which
> has pluggable backends per OS platform.

Good point.  Its a per client thing, and each client would store the
preferences in the way that makes best sense for it.

GConf for GTK things, something else for KDE, and a virsh appropriate
approach for that if/when we get around to it.

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


Re: [libvirt] [RFC] new preferences requirement

2010-12-01 Thread Daniel P. Berrange
On Wed, Dec 01, 2010 at 09:19:30PM +1100, Justin Clift wrote:
> On 01/12/2010, at 8:35 PM, Osier Yang wrote:
> >   Should we add these new preferences(if they are really neccessary)
> > in qemu.conf? or create new config file, e.g. The approch Justin
> > raised up an approch before:
> > http://www.redhat.com/archives/libvir-list/2010-November/msg00651.html
> > 
> >   Though for Justin's approch, IMHO we'd better also to provide a
> > default config file, e.g. "/etc/libvirt/client.conf".
> > 
> >   Any feedback is welcomed, thanks
> 
> When thinking about this more, three levels of preference can be found in
> other applications, and _might_ be the right approach for us to take as well.

Management of preferences belongs in application code, rather than
libvirt. Library APIs need to have standard, predictable behaviour
that apps can rely on in any deployment. We don't want that being
changed globally for all applications by config files.

Even if apps do want configuration data, we can't assume they want the
data stored in configuration files. Any current GTK application will
use GConf for any configuration, or in the future GSettings which
has pluggable backends per OS platform.


>   1) System wide
> 
> Client preferences stored in a location that's applicable to all users.
> 
>   ie:  /etc/libvirt.conf or similar
> 
> We can't put it in the /etc/libvirt/ directory with the present permission
> structure, because /etc/libvirt/ is not world readable.  Would need to be
> in a world readable location (/etc/ ?) or we could relax the perms of
> /etc/libvirt/ (prob not likely).

It is restricted because many of the files below /etc/libvirt contain
passwords and/or other sensitive data, so it can't be opened.

Regards,
Daniel

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


Re: [libvirt] [PATCH] virsh: remove a badly placed line break in virsh -h output

2010-12-01 Thread Osier Yang

于 2010年12月01日 21:35, Justin Clift 写道:

On 02/12/2010, at 12:30 AM, Justin Clift wrote:

The output was previously:

-c | --connect hypervisor connection URI
-r | --readonly connect readonly
-d | --debug   debug level [0-5]
-h | --help this help
-q | --quietquiet mode
-t | --timing   print timing information
-l | --logoutput logging to file
-v | --version[=short]  program version

-V | --version=long version and full options

(note the blank line between the --version types)

This patch removes the extra blank line.
---
tools/virsh.c |2 +-
1 files changed, 1 insertions(+), 1 deletions(-)


Pushed this under the trivial rule.


ah, I just sent patch with fix of this problem before, :-)

http://www.redhat.com/archives/libvir-list/2010-December/msg00012.html

- Osier

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


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

[libvirt] Best virsh group for storage "find-*" commands?

2010-12-01 Thread Justin Clift
Hi us,

Just realised the new groupings of commands in virsh help has
the two storage "find" commands in domain management.

These ones:

  + find-storage-pool-sources-as   find potential storage pool sources
  + find-storage-pool-sources  discover potential storage pool sources

They'd be better placed in the Storage Pool group wouldn't they?

Regards and best wishes,

Justin Clift

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


[libvirt] [PATCH] qemu: Fix typo in qemuTeardownDiskPathDeny

2010-12-01 Thread Osier Yang
typo in error message, it should be by copy-a-paste
from "qemuSetupDiskPathAllow".

* src/qemu/qemu_driver.c (qemuTeardownDiskPathDeny)
---
 src/qemu/qemu_driver.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index fcb90a3..5d90e59 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3401,7 +3401,7 @@ static int qemuTeardownDiskPathDeny(virDomainDiskDefPtr 
disk ATTRIBUTE_UNUSED,
 VIR_DEBUG("Ignoring EACCES for %s", path);
 } else {
 virReportSystemError(-rc,
- _("Unable to allow access for disk path %s"),
+ _("Unable to deny access for disk path %s"),
  path);
 return -1;
 }
--
1.7.3.2

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


[libvirt] [PATCH] virsh: update help for "virsh help help"

2010-12-01 Thread Osier Yang
As virsh help supports both command and command group now,
update "cmdHelp" to print consite help, (this patch is
increment of "7829052757953023b0826e0293ffe18ed4ab89e9").

And also remove redundant empty line in "vshUsage".

* tools/virsh.c
---
 tools/virsh.c |   19 +--
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 010e345..6a9aba2 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -562,13 +562,15 @@ vshReconnect(vshControl *ctl) {
  */
 static const vshCmdInfo info_help[] = {
 {"help", N_("print help")},
-{"desc", N_("Prints global help or command specific help.")},
+{"desc", N_("Prints global help, command specific help, or help for a\n"
+"group of related commands")},

 {NULL, NULL}
 };

 static const vshCmdOptDef opts_help[] = {
-{"command", VSH_OT_DATA, 0, N_("name of command")},
+{"command", VSH_OT_DATA, 0, N_("Prints global help or command specific 
help.")},
+{"group", VSH_OT_DATA, 0, N_("Prints global help or help for a group of 
related commands.")},
 {NULL, 0, 0, NULL}
 };

@@ -577,7 +579,12 @@ cmdHelp(vshControl *ctl, const vshCmd *cmd)
  {
 const vshCmdDef *c;
 const vshCmdGrp *g;
-const char *name = vshCommandOptString(cmd, "command", NULL);
+const char *name;
+
+name = vshCommandOptString(cmd, "command", NULL);
+
+if (!name)
+name = vshCommandOptString(cmd, "group", NULL);

 if (!name) {
 const vshCmdGrp *grp;
@@ -596,8 +603,8 @@ cmdHelp(vshControl *ctl, const vshCmd *cmd)
 vshPrint(ctl, "\n");
 }

- return TRUE;
- }
+return TRUE;
+}

 if ((c = vshCmddefSearch(name))) {
 return vshCmddefHelp(ctl, name);
@@ -11694,7 +11701,7 @@ vshUsage(void)
   "-q | --quietquiet mode\n"
   "-t | --timing   print timing information\n"
   "-l | --logoutput logging to file\n"
-  "-v | --version[=short]  program version\n\n"
+  "-v | --version[=short]  program version\n"
   "-V | --version=long version and full 
options\n\n"
   "  commands (non interactive mode):\n\n"), progname, 
progname);

--
1.7.3.2

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


Re: [libvirt] [PATCH] virsh: remove a badly placed line break in virsh -h output

2010-12-01 Thread Justin Clift
On 02/12/2010, at 12:30 AM, Justin Clift wrote:
> The output was previously:
> 
>-c | --connect hypervisor connection URI
>-r | --readonly connect readonly
>-d | --debug   debug level [0-5]
>-h | --help this help
>-q | --quietquiet mode
>-t | --timing   print timing information
>-l | --logoutput logging to file
>-v | --version[=short]  program version
> 
>-V | --version=long version and full options
> 
> (note the blank line between the --version types)
> 
> This patch removes the extra blank line.
> ---
> tools/virsh.c |2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)

Pushed this under the trivial rule.

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


Re: [libvirt] make syntax-check -> make: *** [sc_check_author_list] Error 1 on libvirt-0.8.5

2010-12-01 Thread Justin Clift
On 01/12/2010, at 9:03 PM, Kenneth Nagin wrote:
> I am receiving syntax error when compiling libvirt-0.8.5.
> However, make without syntax-check completes successfully.

Interesting.  There was a problem with make syntax-check that was patched last
night, after the 0.8.6 release.

Are you able to test the hourly source code snapshot, and see if it works for 
you
there?

  http://libvirt.org/sources/libvirt-git-snapshot.tar.gz

If you can, and the error still crops up, then it's a new one we need to look 
at.
Otherwise it's already been fixed in the source, your choice of which source
tarball version you want to then use. :)

Regards and best wishes,

Justin Clift

--
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


[libvirt] [PATCH] virsh: remove a badly placed line break in virsh -h output

2010-12-01 Thread Justin Clift
The output was previously:

-c | --connect hypervisor connection URI
-r | --readonly connect readonly
-d | --debug   debug level [0-5]
-h | --help this help
-q | --quietquiet mode
-t | --timing   print timing information
-l | --logoutput logging to file
-v | --version[=short]  program version

-V | --version=long version and full options

(note the blank line between the --version types)

This patch removes the extra blank line.
---
 tools/virsh.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 010e345..73d0941 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -11694,7 +11694,7 @@ vshUsage(void)
   "-q | --quietquiet mode\n"
   "-t | --timing   print timing information\n"
   "-l | --logoutput logging to file\n"
-  "-v | --version[=short]  program version\n\n"
+  "-v | --version[=short]  program version\n"
   "-V | --version=long version and full 
options\n\n"
   "  commands (non interactive mode):\n\n"), progname, 
progname);
 
-- 
1.7.3.2

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


Re: [libvirt] [PATCH 0/2] Add unit tests for internal CPU APIs

2010-12-01 Thread Jiri Denemark
> ACK series, but should tests/cputest.c be given a copyright notice?
> Also, make sure 'make syntax-check' passes; I noticed a failure on
> sc_prohibit_empty_lines_at_EOF on tests/sputestdata/x86-nehalem-force.xml.

I fixed both issues (and one possible NULL-pointer dereference in an error
path) and pushed the patches now.

Jirka

--
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 R&D - 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] qemu: Use macro for max and min vnc port instead of number

2010-12-01 Thread Osier Yang
* src/qemu/qemu_driver.c (though MACROS QEMU_VNC_PORT_MAX, and
QEMU_VNC_PORT_MIN are defined at the beginning, numbers (65535, 5900)
are still used, replace them)

---
 src/qemu/qemu_driver.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index fcb90a3..f733482 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2964,7 +2964,7 @@ static int qemudNextFreePort(struct qemud_driver *driver,
  int startPort) {
 int i;

-for (i = startPort ; i < 65535 ; i++) {
+for (i = startPort ; i < QEMU_VNC_PORT_MAX; i++) {
 int fd;
 int reuse = 1;
 struct sockaddr_in addr;
@@ -3939,7 +3939,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
 if (vm->def->ngraphics == 1) {
 if (vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
 vm->def->graphics[0]->data.vnc.autoport) {
-int port = qemudNextFreePort(driver, 5900);
+int port = qemudNextFreePort(driver, QEMU_VNC_PORT_MIN);
 if (port < 0) {
 qemuReportError(VIR_ERR_INTERNAL_ERROR,
 "%s", _("Unable to find an unused VNC port"));
@@ -3948,7 +3948,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
 vm->def->graphics[0]->data.vnc.port = port;
 } else if (vm->def->graphics[0]->type == 
VIR_DOMAIN_GRAPHICS_TYPE_SPICE &&
vm->def->graphics[0]->data.spice.autoport) {
-int port = qemudNextFreePort(driver, 5900);
+int port = qemudNextFreePort(driver, QEMU_VNC_PORT_MIN);
 int tlsPort = -1;
 if (port < 0) {
 qemuReportError(VIR_ERR_INTERNAL_ERROR,
@@ -7380,7 +7380,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn,
 for (i = 0 ; i < def->ngraphics ; i++) {
 if (def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
 def->graphics[i]->data.vnc.autoport)
-def->graphics[i]->data.vnc.port = 5900;
+def->graphics[i]->data.vnc.port = QEMU_VNC_PORT_MIN;
 }
 emulator = def->emulator;

--
1.7.3.2

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


[libvirt] [PATCH] Fix flaw in thread creation APIs

2010-12-01 Thread Daniel P. Berrange
The arguments passed to the thread function must be allocated on
the heap, rather than the stack, since it is possible for the
spawning thread to continue before the new thread runs at all.
In such a case, it is possible that the area of stack where the
thread args were stored is overwritten.

* src/util/threads-pthread.c, src/util/threads-win32.c: Allocate
  thread arguments on the heap
---
 src/util/threads-pthread.c |   15 +--
 src/util/threads-win32.c   |   17 ++---
 2 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/src/util/threads-pthread.c b/src/util/threads-pthread.c
index 02070ae..bff4979 100644
--- a/src/util/threads-pthread.c
+++ b/src/util/threads-pthread.c
@@ -26,6 +26,8 @@
 # include 
 #endif
 
+#include "memory.h"
+
 
 /* Nothing special required for pthreads */
 int virThreadInitialize(void)
@@ -143,6 +145,7 @@ static void *virThreadHelper(void *data)
 {
 struct virThreadArgs *args = data;
 args->func(args->opaque);
+VIR_FREE(args);
 return NULL;
 }
 
@@ -151,17 +154,25 @@ int virThreadCreate(virThreadPtr thread,
 virThreadFunc func,
 void *opaque)
 {
-struct virThreadArgs args = { func, opaque };
+struct virThreadArgs *args;
 pthread_attr_t attr;
 pthread_attr_init(&attr);
+if (VIR_ALLOC(args) < 0)
+return -1;
+
+args->func = func;
+args->opaque = opaque;
+
 if (!joinable)
 pthread_attr_setdetachstate(&attr, 1);
 
-int ret = pthread_create(&thread->thread, &attr, virThreadHelper, &args);
+int ret = pthread_create(&thread->thread, &attr, virThreadHelper, args);
 if (ret != 0) {
+VIR_FREE(args);
 errno = ret;
 return -1;
 }
+/* New thread owns 'args' in success case, so don't free */
 return 0;
 }
 
diff --git a/src/util/threads-win32.c b/src/util/threads-win32.c
index 33be4cf..436b3bd 100644
--- a/src/util/threads-win32.c
+++ b/src/util/threads-win32.c
@@ -230,6 +230,8 @@ static void virThreadHelperDaemon(void *data)
 
 TlsSetValue(selfkey, NULL);
 CloseHandle(self.thread);
+
+VIR_FREE(args);
 }
 
 static unsigned int __stdcall virThreadHelperJoinable(void *data)
@@ -249,6 +251,8 @@ static unsigned int __stdcall virThreadHelperJoinable(void 
*data)
 
 TlsSetValue(selfkey, NULL);
 CloseHandle(self.thread);
+
+VIR_FREE(args);
 return 0;
 }
 
@@ -257,17 +261,24 @@ int virThreadCreate(virThreadPtr thread,
 virThreadFunc func,
 void *opaque)
 {
-struct virThreadArgs args = { func, opaque };
+struct virThreadArgs *args;
+
+if (VIR_ALLOC(args) < 0)
+return -1;
+
+args->func = func;
+args->opaque = opaque;
+
 thread->joinable = joinable;
 if (joinable) {
 thread->thread = (HANDLE)_beginthreadex(NULL, 0,
 virThreadHelperJoinable,
-&args, 0, NULL);
+args, 0, NULL);
 if (thread->thread == 0)
 return -1;
 } else {
 thread->thread = (HANDLE)_beginthread(virThreadHelperDaemon,
-  0, &args);
+  0, args);
 if (thread->thread == (HANDLE)-1L)
 return -1;
 }
-- 
1.7.2.3

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


Re: [libvirt] [RFC] new preferences requirement

2010-12-01 Thread Daniel P. Berrange
On Wed, Dec 01, 2010 at 05:35:38PM +0800, Osier Yang wrote:
> Hi, all
> 
>We have some new requirements of preferences, I listed
> which of them I known, and think is useful as follows:
> 
> 1) for the path of x509 certificate and keys of client
> 
>The path of x509 certificate and keys of client is hard
> coded in remote driver. e.g.
> 
>/* 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"

We can't assume one set of certs/keys is suitable for all
URIs, so making this a preference setting doesn't help. There
needs to be a parameter in the URI to specify a cert/key name
to override the defaults on a per-connection basis

> 2) for default default driver and subdriver for disk image
> 
>Another requirement of new preference is default driver and subdriver
> for disk images, currently we use "phy" for "driver" in virsh, and
> "raw" for "subdriver" in qemu driver by default if user doesn't specify
> them, it causes bugs, though we could say to user "you should use
> options --driver and --subdriver", but these two options are optional.
> 
>IMHO, the best solution for those bugs is to provide new preferences.

virsh is broken here. It shouldn't be setting the driver if the
user doesn't specify it. The libvirt hypervisor specific drivers
know the correct defaults if omitted, so virsh shouldn't try to
guess this (wrongly) itself.

> 3) for default NIC and storage type
> 
>"Chris Phillips" raised up the requirement not long ago:
> 
>http://www.redhat.com/archives/libvirt-users/2010-November/msg00033.html

This doesn't belong in libvirt. See my reply in that thread.

> 
> 
>Should we add these new preferences(if they are really neccessary)
> in qemu.conf? or create new config file, e.g. The approch Justin
> raised up an approch before:
> http://www.redhat.com/archives/libvir-list/2010-November/msg00651.html
> 
>Though for Justin's approch, IMHO we'd better also to provide a
> default config file, e.g. "/etc/libvirt/client.conf".

Library APIs like libvirt shouldn't really rely on preference files,
because such a file would silently change behaviour in ways that
applications using the API may not expect. ie the preference
may work nicely for one app/user of libvirt, but not for another
app. Environment variables would cause similar problems too. Anything
that needs to be configured should be configurable via the APIs or
XML.

Regards,
Daniel

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


  1   2   >