mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-11 07:55:58 -06:00
Check that QEMU is still alive while reading startup output.
By checking the pid every retry period, we can quickly determine if the process crashed at startup, rather than make the user wait for the entire timeout (3 seconds).
This commit is contained in:
parent
a331653dad
commit
0c8a9d2d51
@ -1,3 +1,8 @@
|
|||||||
|
Mon May 11 09:51:00 EDT 2009 Cole Robinson <crobinso@redhat.com>
|
||||||
|
|
||||||
|
* src/qemu_driver.c : Check that QEMU is still alive while
|
||||||
|
reading startup output.
|
||||||
|
|
||||||
Mon May 11 09:44:40 EDT 2009 Cole Robinson <crobinso@redhat.com>
|
Mon May 11 09:44:40 EDT 2009 Cole Robinson <crobinso@redhat.com>
|
||||||
|
|
||||||
* src/util.[ch] : Add pidfile argument to __virExec
|
* src/util.[ch] : Add pidfile argument to __virExec
|
||||||
|
@ -744,29 +744,40 @@ qemudReadLogOutput(virConnectPtr conn,
|
|||||||
int timeout)
|
int timeout)
|
||||||
{
|
{
|
||||||
int retries = timeout*10;
|
int retries = timeout*10;
|
||||||
|
int got = 0;
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
|
|
||||||
while (retries) {
|
while (retries) {
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
size_t got = 0;
|
int isdead = 0;
|
||||||
|
|
||||||
while((ret = read(fd, buf+got, buflen-got-1)) > 0) {
|
if (kill(vm->pid, 0) == -1 && errno == ESRCH)
|
||||||
got += ret;
|
isdead = 1;
|
||||||
buf[got] = '\0';
|
|
||||||
if ((buflen-got-1) == 0) {
|
|
||||||
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("Out of space while reading %s log output"), what);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret < 0 && errno != EINTR) {
|
ret = saferead(fd, buf+got, buflen-got-1);
|
||||||
|
if (ret < 0) {
|
||||||
virReportSystemError(conn, errno,
|
virReportSystemError(conn, errno,
|
||||||
_("Failure while reading %s log output"),
|
_("Failure while reading %s log output"),
|
||||||
what);
|
what);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
got += ret;
|
||||||
|
buf[got] = '\0';
|
||||||
|
if (got == buflen-1) {
|
||||||
|
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("Out of space while reading %s log output"),
|
||||||
|
what);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isdead) {
|
||||||
|
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("Process exited while reading %s log output"),
|
||||||
|
what);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ret = func(conn, vm, buf, fd);
|
ret = func(conn, vm, buf, fd);
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user