[libvirt] QMP fallback race in libvirt
Hi, Eric asked me to move this here from #virt so it doesn't get forgotten. I hit a weird bug in a new install of libvirt on Debian Jessie this week where a vm could not be configured to use any CPU type except passthrough. After much digging and headscratching, the immediate cause for that turns out to be one of the (three) files in the qemu/capabilities cache being generated wrongly the first time that libvirtd was started. Instead of being generated from the QMP queries, it appears to have fallen back to the old method of scraping 'qemu -cpu help', and since the output of that changed with qemu 2.0 it leads to things like: and hilarity then ensues when cpuModelIsAllowed() is called by x86Decode(). Since only one of the cache files there was corrupted like this, it would appear libvirt either didn't wait long enough, or didn't try hard enough, to get a connection to the monitor for the QMP query on what was probably also the very first time qemu had been started on this host machine. After nuking the cache files and restarting libvirtd they were then correctly regenerated, and things began to work as expected. This was all done on a new clean install of the host machine, so there was nothing around from any earlier versions to get tangled up with, and possibly means qemu had some first time init of its own to do which took some time before it was ready to be queried. I am also seeing bursts of several of these warnings in the logs: libvirtd[26475]: This thread seems to be the async job owner; entering monitor without asking for a nested job is dangerous Which I haven't confirmed as being related, but doesn't seem to be obviously unrelated either, and at worst is a separate bug. Cheers, Ron -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] Kernel command line support for UML
When experimenting with libvirt and UML I found it necessary to add support for additional kernel command line arguments. Ron diff -up libvirt-0.6.5/src/uml_conf.c.uml-cmdline libvirt-0.6.5/src/uml_conf.c --- libvirt-0.6.5/src/uml_conf.c.uml-cmdline2009-07-10 16:28:51.0 +0100 +++ libvirt-0.6.5/src/uml_conf.c2009-07-27 19:39:59.0 +0100 @@ -326,6 +326,31 @@ umlBuildCommandLineChr(virConnectPtr con } /* + * Null-terminate the current argument and return a pointer to the next. + * This should follow the same rules as the Linux kernel: arguments are + * separated by spaces; arguments can be quoted with double quotes; double + * quotes can't be escaped. + */ +static char *umlNextArg(char *args) +{ +int in_quote = 0; + +for (; *args; args++) { +if (*args == ' ' && !in_quote) { +*args++ = '\0'; +break; +} +if (*args == '"') +in_quote = !in_quote; +} + +while (*args == ' ') +args++; + +return args; +} + +/* * Constructs a argv suitable for launching uml with config defined * for a given virtual machine. */ @@ -342,6 +367,7 @@ int umlBuildCommandLine(virConnectPtr co const char **qargv = NULL; int qenvc = 0, qenva = 0; const char **qenv = NULL; +char *cmdline = NULL; uname(&ut); @@ -474,6 +500,22 @@ int umlBuildCommandLine(virConnectPtr co ADD_ARG(ret); } +if (vm->def->os.cmdline) { +char *args, *next_arg; +if ((cmdline = strdup(vm->def->os.cmdline)) == NULL) +goto no_memory; + +args = cmdline; +while (*args == ' ') +args++; + +while (*args) { +next_arg = umlNextArg(args); +ADD_ARG_LIT(args); +args = next_arg; +} +} + ADD_ARG(NULL); ADD_ENV(NULL); @@ -495,6 +537,7 @@ int umlBuildCommandLine(virConnectPtr co VIR_FREE((qenv)[i]); VIR_FREE(qenv); } +VIR_FREE(cmdline); return -1; #undef ADD_ARG -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] PATCH: 11/28: Reduce return points for UML driver
"Daniel P. Berrange" <[EMAIL PROTECTED]> wrote: > static int umlDomainShutdown(virDomainPtr dom) { >-struct uml_driver *driver = (struct uml_driver *)dom->conn->privateData; >-virDomainObjPtr vm = virDomainFindByID(&driver->domains, dom->id); >-char* info; >+struct uml_driver *driver = dom->conn->privateData; >+virDomainObjPtr vm; >+char *info; >+int ret = -1; > >+vm = virDomainFindByID(&driver->domains, dom->id); > if (!vm) { > umlReportError(dom->conn, dom, NULL, VIR_ERR_INVALID_DOMAIN, > _("no domain with matching id %d"), dom->id); >-return -1; >+goto cleanup; > } > > #if 0 > if (umlMonitorCommand(driver, vm, "system_powerdown", &info) < 0) { > umlReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED, > "%s", _("shutdown operation failed")); >-return -1; >+goto cleanup; > } >+ret = 0; > #endif >+ >+cleanup: > VIR_FREE(info); >-return 0; >+return ret; > > } info should be initialised to NULL, otherwise the VIR_FREE will fail. With the umlMonitorCommand if'ed out this is also broken before the patch, which is how I came to notice it. Ron -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Concerning umlInotifyEvent
"Daniel P. Berrange" <[EMAIL PROTECTED]> wrote: >That's a symptom of a bug earlier on. Try this patch: Thanks, Daniel, that seems to have fixed it. Ron -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] Concerning umlInotifyEvent
At the top of umlInotifyEvent in uml_driver.c there is this test: if (watch != driver->inotifyWatch) return; This doesn't seem to be correct. I have to comment out the test to get libvirtd to work with UML. Ron -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list