From: "MATSUDA, Daiki" <matsudadik@intellilink.co.jp>
To: qemu-devel@nongnu.org, "MATSUDA, Daiki" <matsudadik@intellilink.co.jp>
Subject: [Qemu-devel] [PATCH] GuestAgent: PIDFILE remains when daemon start fails
Date: Fri, 06 Jan 2012 07:16:23 +0900 [thread overview]
Message-ID: <4F062137.3070704@intellilink.co.jp> (raw)
Hi, all.
I am trying QEMU Guest Agent and encountered a small bug. It is that the
PIDFILE remains when daemon start fails. And maybe forgotton to g_free().
MATSUDA, Daiki
diff -uNrp qemu/qemu-ga.c
qemu-c47f3223658119219bbe0b8d09da733d1c06e76f/qemu-ga.c
--- qemu/qemu-ga.c 2012-01-05 01:06:25.000000000 +0900
+++ qemu-c47f3223658119219bbe0b8d09da733d1c06e76f/qemu-ga.c 2012-01-06
07:07:03.807872085 +0900
@@ -49,6 +49,13 @@ struct GAState {
};
static struct GAState *ga_state;
+const char *pidfile = QGA_PIDFILE_DEFAULT;
+
+static void cleanup(void)
+{
+ g_free(ga_state);
+ unlink(pidfile);
+}
static void quit_handler(int sig)
{
@@ -70,6 +77,7 @@ static void register_signal_handlers(voi
ret = sigaction(SIGINT, &sigact, NULL);
if (ret == -1) {
g_error("error configuring signal handler: %s", strerror(errno));
+ cleanup();
exit(EXIT_FAILURE);
}
ret = sigaction(SIGTERM, &sigact, NULL);
@@ -485,6 +493,7 @@ static void init_guest_agent(GAState *s)
if (s->path == NULL) {
if (strcmp(s->method, "virtio-serial") != 0) {
g_critical("must specify a path for this channel");
+ cleanup();
exit(EXIT_FAILURE);
}
/* try the default path for the virtio-serial port */
@@ -496,17 +505,20 @@ static void init_guest_agent(GAState *s)
fd = qemu_open(s->path, O_RDWR | O_NONBLOCK | O_ASYNC);
if (fd == -1) {
g_critical("error opening channel: %s", strerror(errno));
+ cleanup();
exit(EXIT_FAILURE);
}
ret = conn_channel_add(s, fd);
if (ret) {
g_critical("error adding channel to main loop");
+ cleanup();
exit(EXIT_FAILURE);
}
next reply other threads:[~2012-01-05 22:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-05 22:16 MATSUDA, Daiki [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-01-05 22:26 [Qemu-devel] [PATCH] GuestAgent: PIDFILE remains when daemon start fails MATSUDA, Daiki
2012-01-06 0:18 ` Michael Roth
2012-01-06 10:56 ` Daniel P. Berrange
2012-01-06 17:00 ` Michael Roth
2012-01-06 17:05 ` Daniel P. Berrange
2012-01-06 19:06 ` Luiz Capitulino
2012-01-06 20:09 ` Michael Roth
2012-01-06 20:18 ` Luiz Capitulino
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F062137.3070704@intellilink.co.jp \
--to=matsudadik@intellilink.co.jp \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.