[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] Change the semantics of GetDomainPath so that it always succeeds, regardless of
# HG changeset patch # User emellor@xxxxxxxxxxxxxxxxxxxxxx # Node ID a90d670c98b9df3bd32a107594882ed33c598917 # Parent 5a728a884242b7aa2a0ab6d998adbc117b0ef917 Change the semantics of GetDomainPath so that it always succeeds, regardless of whether a domain has been introduced to the store. Added a separate message XS_IS_DOMAIN_INTRODUCED and API for that (xs_is_domain_introduced) to determine whether the domain has really been introduced. This change means that the tools can determine the correct domain path earlier in the domain creation process, which is particularly a factor with live migration, as it allows us to create the devices earlier in the process, and unpause the new domain before performing the introduce. Until recently we already had these features, but the simplification of the interface between xend and xenstored caused breakage. No longer clear out the domain path when a domain is introduced -- this was a hack to work around the recent problematic semantics of GetDomainPath. Do not write the contents of the info block to the store. All the configuration info is written to the /vm path, and anything else in the info block is either dealt with explicitly or is ephemeral and has no place in the store. Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx> diff -r 5a728a884242 -r a90d670c98b9 tools/console/daemon/io.c --- a/tools/console/daemon/io.c Sun Oct 23 21:34:13 2005 +++ b/tools/console/daemon/io.c Sun Oct 23 21:45:15 2005 @@ -301,10 +301,7 @@ } dom->domid = domid; - dom->conspath = xs_get_domain_path(xs, dom->domid); - if (dom->conspath == NULL) - goto out; s = realloc(dom->conspath, strlen(dom->conspath) + strlen("/console") + 1); if (s == NULL) diff -r 5a728a884242 -r a90d670c98b9 tools/python/xen/lowlevel/xs/xs.c --- a/tools/python/xen/lowlevel/xs/xs.c Sun Oct 23 21:34:13 2005 +++ b/tools/python/xen/lowlevel/xs/xs.c Sun Oct 23 21:45:15 2005 @@ -795,11 +795,10 @@ } #define xspy_get_domain_path_doc "\n" \ - "Return store path of domain.\n" \ + "Return store path of domain, whether or not the domain exists.\n" \ " domid [int]: domain id\n" \ "\n" \ "Returns: [string] domain store path.\n" \ - " None if domid doesn't exist.\n" \ "Raises RuntimeError on error.\n" \ "\n" diff -r 5a728a884242 -r a90d670c98b9 tools/python/xen/xend/XendCheckpoint.py --- a/tools/python/xen/xend/XendCheckpoint.py Sun Oct 23 21:34:13 2005 +++ b/tools/python/xen/xend/XendCheckpoint.py Sun Oct 23 21:45:15 2005 @@ -143,6 +143,8 @@ if handler.store_mfn is None or handler.console_mfn is None: raise XendError('Could not read store/console MFN') + + dominfo.unpause() dominfo.completeRestore(handler.store_mfn, handler.console_mfn) diff -r 5a728a884242 -r a90d670c98b9 tools/python/xen/xend/XendDomainInfo.py --- a/tools/python/xen/xend/XendDomainInfo.py Sun Oct 23 21:34:13 2005 +++ b/tools/python/xen/xend/XendDomainInfo.py Sun Oct 23 21:45:15 2005 @@ -198,7 +198,7 @@ vm = XendDomainInfo(xeninfo, domid, dompath, True) except Exception, exn: - if True: + if priv: log.warn(str(exn)) vm = XendDomainInfo(xeninfo, domid, dompath, True) @@ -223,7 +223,9 @@ try: vm.construct() vm.storeVmDetails() + vm.createDevices() vm.createChannels() + vm.storeDomDetails() return vm except: vm.destroy() @@ -337,8 +339,8 @@ log.debug("domain_getinfo(%d) failed, ignoring: %s", dom, str(err)) return None + class XendDomainInfo: - def __init__(self, info, domid = None, dompath = None, augment = False): @@ -558,13 +560,13 @@ def completeRestore(self, store_mfn, console_mfn): + log.debug("XendDomainInfo.completeRestore") + self.store_mfn = store_mfn self.console_mfn = console_mfn self.introduceDomain() - self.create_devices() self.storeDomDetails() - self.unpause() self.refreshShutdown() @@ -596,10 +598,6 @@ 'console/limit': str(xroot.get_console_limit() * 1024), 'memory/target': str(self.info['memory_KiB']) } - - for (k, v) in self.info.items(): - if v: - to_store[k] = str(v) def f(n, v): if v is not None: @@ -1055,6 +1053,10 @@ raise VmError('Creating domain failed: name=%s' % self.info['name']) + self.dompath = GetDomainPath(self.domid) + + self.removeDom() + # Set maximum number of vcpus in domain xc.domain_max_vcpus(self.domid, int(self.info['vcpus'])) @@ -1065,8 +1067,6 @@ assert self.store_port is not None IntroduceDomain(self.domid, self.store_mfn, self.store_port) - self.dompath = GetDomainPath(self.domid) - assert self.dompath def initDomain(self): @@ -1105,7 +1105,7 @@ self.introduceDomain() - self.create_devices() + self.createDevices() self.info['start_time'] = time.time() @@ -1209,22 +1209,20 @@ raise - def create_configured_devices(self): + ## public: + + def createDevices(self): + """Create the devices for a vm. + + @raise: VmError for invalid devices + """ + for (n, c) in self.info['device']: self.createDevice(n, c) - - def create_devices(self): - """Create the devices for a vm. - - @raise: VmError for invalid devices - """ - self.create_configured_devices() if self.image: self.image.createDeviceModel() - - ## public: def device_create(self, dev_config): """Create a new device. diff -r 5a728a884242 -r a90d670c98b9 tools/xenstore/xenstored_core.c --- a/tools/xenstore/xenstored_core.c Sun Oct 23 21:34:13 2005 +++ b/tools/xenstore/xenstored_core.c Sun Oct 23 21:45:15 2005 @@ -166,6 +166,7 @@ case XS_SET_PERMS: return "SET_PERMS"; case XS_WATCH_EVENT: return "WATCH_EVENT"; case XS_ERROR: return "ERROR"; + case XS_IS_DOMAIN_INTRODUCED: return "XS_IS_DOMAIN_INTRODUCED"; default: return "**UNKNOWN**"; } @@ -1001,16 +1002,6 @@ } -void internal_rm(const char *name) -{ - struct node *node = read_node(NULL, name); - if (!node) { - return; - } - _rm(NULL, node, name); -} - - static void do_get_perms(struct connection *conn, const char *name) { struct node *node; @@ -1151,6 +1142,10 @@ case XS_INTRODUCE: do_introduce(conn, in); + break; + + case XS_IS_DOMAIN_INTRODUCED: + do_is_domain_introduced(conn, onearg(in)); break; case XS_RELEASE: diff -r 5a728a884242 -r a90d670c98b9 tools/xenstore/xenstored_core.h --- a/tools/xenstore/xenstored_core.h Sun Oct 23 21:34:13 2005 +++ b/tools/xenstore/xenstored_core.h Sun Oct 23 21:45:15 2005 @@ -155,9 +155,6 @@ struct connection *new_connection(connwritefn_t *write, connreadfn_t *read); -void internal_rm(const char *name); - - /* Is this a valid node name? */ bool is_valid_nodename(const char *node); diff -r 5a728a884242 -r a90d670c98b9 tools/xenstore/xenstored_domain.c --- a/tools/xenstore/xenstored_domain.c Sun Oct 23 21:34:13 2005 +++ b/tools/xenstore/xenstored_domain.c Sun Oct 23 21:45:15 2005 @@ -250,6 +250,11 @@ return ((intf->rsp_prod - intf->rsp_cons) != XENSTORE_RING_SIZE); } +static char *talloc_domain_path(void *context, unsigned int domid) +{ + return talloc_asprintf(context, "/local/domain/%u", domid); +} + static struct domain *new_domain(void *context, unsigned int domid, unsigned long mfn, int port) { @@ -262,7 +267,7 @@ domain->port = 0; domain->shutdown = 0; domain->domid = domid; - domain->path = talloc_asprintf(domain, "/local/domain/%d", domid); + domain->path = talloc_domain_path(domain, domid); domain->interface = xc_map_foreign_range( *xc_handle, domain->domid, getpagesize(), PROT_READ|PROT_WRITE, mfn); @@ -271,8 +276,6 @@ list_add(&domain->list, &domains); talloc_set_destructor(domain, destroy_domain); - - internal_rm(domain->path); /* Tell kernel we're interested in this event. */ bind.remote_domain = domid; @@ -403,25 +406,37 @@ void do_get_domain_path(struct connection *conn, const char *domid_str) { - struct domain *domain; - unsigned int domid; + char *path; if (!domid_str) { send_error(conn, EINVAL); return; } + path = talloc_domain_path(conn, atoi(domid_str)); + + send_reply(conn, XS_GET_DOMAIN_PATH, path, strlen(path) + 1); + + talloc_free(path); +} + +void do_is_domain_introduced(struct connection *conn, const char *domid_str) +{ + int result; + unsigned int domid; + + if (!domid_str) { + send_error(conn, EINVAL); + return; + } + domid = atoi(domid_str); if (domid == DOMID_SELF) - domain = conn->domain; + result = 1; else - domain = find_domain_by_domid(domid); - - if (!domain) - send_error(conn, ENOENT); - else - send_reply(conn, XS_GET_DOMAIN_PATH, domain->path, - strlen(domain->path) + 1); + result = (find_domain_by_domid(domid) != NULL); + + send_reply(conn, XS_IS_DOMAIN_INTRODUCED, result ? "T" : "F", 2); } static int close_xc_handle(void *_handle) diff -r 5a728a884242 -r a90d670c98b9 tools/xenstore/xenstored_domain.h --- a/tools/xenstore/xenstored_domain.h Sun Oct 23 21:34:13 2005 +++ b/tools/xenstore/xenstored_domain.h Sun Oct 23 21:45:15 2005 @@ -26,6 +26,9 @@ void do_introduce(struct connection *conn, struct buffered_data *in); /* domid */ +void do_is_domain_introduced(struct connection *conn, const char *domid_str); + +/* domid */ void do_release(struct connection *conn, const char *domid_str); /* domid */ diff -r 5a728a884242 -r a90d670c98b9 tools/xenstore/xs.c --- a/tools/xenstore/xs.c Sun Oct 23 21:34:13 2005 +++ b/tools/xenstore/xs.c Sun Oct 23 21:45:15 2005 @@ -696,22 +696,35 @@ ARRAY_SIZE(iov), NULL)); } +static void * single_with_domid(struct xs_handle *h, + enum xsd_sockmsg_type type, + unsigned int domid) +{ + char domid_str[MAX_STRLEN(domid)]; + + sprintf(domid_str, "%u", domid); + + return xs_single(h, NULL, type, domid_str, NULL); +} + bool xs_release_domain(struct xs_handle *h, unsigned int domid) { + return xs_bool(single_with_domid(h, XS_RELEASE, domid)); +} + +char *xs_get_domain_path(struct xs_handle *h, unsigned int domid) +{ char domid_str[MAX_STRLEN(domid)]; sprintf(domid_str, "%u", domid); - return xs_bool(xs_single(h, NULL, XS_RELEASE, domid_str, NULL)); -} - -char *xs_get_domain_path(struct xs_handle *h, unsigned int domid) -{ - char domid_str[MAX_STRLEN(domid)]; - - sprintf(domid_str, "%u", domid); - return xs_single(h, NULL, XS_GET_DOMAIN_PATH, domid_str, NULL); +} + +bool xs_is_domain_introduced(struct xs_handle *h, unsigned int domid) +{ + return strcmp("F", + single_with_domid(h, XS_IS_DOMAIN_INTRODUCED, domid)); } /* Only useful for DEBUG versions */ diff -r 5a728a884242 -r a90d670c98b9 tools/xenstore/xs.h --- a/tools/xenstore/xs.h Sun Oct 23 21:34:13 2005 +++ b/tools/xenstore/xs.h Sun Oct 23 21:45:15 2005 @@ -140,6 +140,10 @@ */ char *xs_get_domain_path(struct xs_handle *h, unsigned int domid); +/* Return whether the domain specified has been introduced to xenstored. + */ +bool xs_is_domain_introduced(struct xs_handle *h, unsigned int domid); + /* Only useful for DEBUG versions */ char *xs_debug_command(struct xs_handle *h, const char *cmd, void *data, unsigned int len); diff -r 5a728a884242 -r a90d670c98b9 xen/include/public/io/xs_wire.h --- a/xen/include/public/io/xs_wire.h Sun Oct 23 21:34:13 2005 +++ b/xen/include/public/io/xs_wire.h Sun Oct 23 21:45:15 2005 @@ -47,6 +47,7 @@ XS_SET_PERMS, XS_WATCH_EVENT, XS_ERROR, + XS_IS_DOMAIN_INTRODUCED }; #define XS_WRITE_NONE "NONE" _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |