From 1b413f5db557ea8ca85dbfe5d867f37542b51473 Mon Sep 17 00:00:00 2001 From: kraxel Date: Thu, 30 Aug 2007 13:14:59 +0000 Subject: fix libvirt polling --- xenscreen.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/xenscreen.c b/xenscreen.c index 1e783f9..d77c96d 100644 --- a/xenscreen.c +++ b/xenscreen.c @@ -33,6 +33,7 @@ struct dom { char tty[BUFSIZE]; int connected; int destroyed; + int watched; struct list_head next; }; static LIST_HEAD(doms); @@ -287,7 +288,13 @@ static void libvirt_scan(virConnectPtr conn, int boot) if (dom) { /* have it */ dom->destroyed = 0; - continue; + if (dom->connected) + continue; + /* try again a few times in case we have no tty, + * it may show up a little later ... */ + if (dom->watched > 8) + continue; + dom->watched++; } /* new one */ vdom = virDomainLookupByID(conn, ids[i]); @@ -295,11 +302,13 @@ static void libvirt_scan(virConnectPtr conn, int boot) xml = virDomainGetXMLDesc(vdom, 0); if (!name || !xml) continue; + // fprintf(stderr, "\n-- xmldesc --\n%s\n--\n", xml); dom = get_dom(ids[i]); snprintf(dom->name, sizeof(dom->name), "%s", name); libvirt_xml_xpath_str(xml, "string(/domain/devices/console/@tty)", dom->tty, sizeof(dom->tty)); - fprintf(stderr, "libvirt debug: %s: tty=\"%s\"\n", dom->name, dom->tty); + fprintf(stderr, "[ libvirt poll debug: %s (%d): tty=\"%s\" ]\n", + dom->name, dom->watched, dom->tty); try_attach_domain(dom, boot); } free(ids); -- cgit