[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] Many files:
ChangeSet 1.1662.1.21, 2005/06/09 10:01:57+01:00, cl349@xxxxxxxxxxxxxxxxxxxx Many files: Switch to xenstore for storing persistent information. Signed-off-by: Mike Wray <mike.wray@xxxxxx> Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx> XendDomain.py | 83 +++++++++++-------- XendDomainInfo.py | 212 +++++++++++++++++++++++++++------------------------ XendRoot.py | 10 -- XendVnet.py | 22 ++--- image.py | 40 ++++----- server/blkif.py | 23 ++++- server/channel.py | 79 ++++++++++++++++++- server/console.py | 7 + server/controller.py | 71 +++++++++++++++-- server/netif.py | 52 ++++++++++++ server/usbif.py | 6 + xenstore/xsobj.py | 5 - 12 files changed, 420 insertions(+), 190 deletions(-) diff -Nru a/tools/python/xen/xend/XendDomain.py b/tools/python/xen/xend/XendDomain.py --- a/tools/python/xen/xend/XendDomain.py 2005-06-09 13:10:14 -04:00 +++ b/tools/python/xen/xend/XendDomain.py 2005-06-09 13:10:14 -04:00 @@ -23,7 +23,8 @@ from xen.xend import scheduler from xen.xend.server import channel from xen.xend.server import relocate -from xen.xend import XendDB +from xen.xend.uuid import getUuid +from xen.xend.xenstore import XenNode, DBMap __all__ = [ "XendDomain" ] @@ -40,9 +41,6 @@ """Index of all domains. Singleton. """ - """Path to domain database.""" - dbpath = "domain" - """Dict of domain info indexed by domain id.""" domains = None @@ -53,7 +51,7 @@ # So we stuff the XendDomain instance (self) into xroot's components. xroot.add_component("xen.xend.XendDomain", self) self.domains = XendDomainDict() - self.db = XendDB.XendDB(self.dbpath) + self.dbmap = DBMap(db=XenNode("/domain")) eserver.subscribe('xend.virq', self.onVirq) self.initial_refresh() @@ -96,11 +94,18 @@ """Refresh initial domain info from db. """ doms = self.xen_domains() - for config in self.db.fetchall("").values(): - domid = int(sxp.child_value(config, 'id')) - if domid in doms: + self.dbmap.readDB() + for domdb in self.dbmap.values(): + try: + domid = int(domdb.id) + except: + domid = None + # XXX if domid in self.domains, then something went wrong + if (domid is None) or (domid in self.domains): + domdb.delete() + elif domid in doms: try: - self._new_domain(config, doms[domid]) + self._new_domain(domdb, doms[domid]) except Exception, ex: log.exception("Error recreating domain info: id=%d", domid) self._delete_domain(domid) @@ -108,27 +113,20 @@ self._delete_domain(domid) self.refresh(cleanup=True) - def sync_domain(self, info): - """Sync info for a domain to disk. - - info domain info - """ - self.db.save(str(info.id), info.sxpr()) - def close(self): pass - def _new_domain(self, savedinfo, info): + def _new_domain(self, db, info): """Create a domain entry from saved info. - @param savedinfo: saved info from the db + @param db: saved info from the db @param info: domain info from xen @return: domain """ - uuid = sxp.child_value(savedinfo, 'uuid') - dominfo = XendDomainInfo.recreate(savedinfo, info, uuid) + log.error(db) + log.error(db.uuid) + dominfo = XendDomainInfo.recreate(db, info) self.domains[dominfo.id] = dominfo - self.sync_domain(dominfo) return dominfo def _add_domain(self, info, notify=True): @@ -141,11 +139,11 @@ for i, d in self.domains.items(): if i != d.id: del self.domains[i] - self.db.delete(str(i)) + self.dbmap.delete(d.uuid) if info.id in self.domains: notify = False self.domains[info.id] = info - self.sync_domain(info) + info.exportToDB(save=True) if notify: eserver.inject('xend.domain.create', [info.name, info.id]) @@ -155,12 +153,26 @@ @param id: domain id @param notify: send a domain died event if true """ + try: + if self.xen_domain(id): + return + except: + pass info = self.domains.get(id) if info: del self.domains[id] - self.db.delete(str(id)) + info.cleanup() + info.delete() if notify: eserver.inject('xend.domain.died', [info.name, info.id]) + # XXX this should not be needed + for domdb in self.dbmap.values(): + try: + domid = int(domdb.id) + except: + domid = None + if (domid is None) or (domid == id): + domdb.delete() def reap(self): """Look for domains that have crashed or stopped. @@ -263,8 +275,7 @@ @param config: configuration @return: domain """ - dominfo = XendDomainInfo.create(config) - self._add_domain(dominfo) + dominfo = XendDomainInfo.create(self.dbmap, config) return dominfo def domain_restart(self, dominfo): @@ -277,7 +288,6 @@ [dominfo.name, dominfo.id, "begin"]) try: dominfo.restart() - self._add_domain(dominfo) log.info('Restarted domain name=%s id=%s', dominfo.name, dominfo.id) eserver.inject("xend.domain.restart", [dominfo.name, dominfo.id, "success"]) @@ -297,8 +307,7 @@ """ config = sxp.child_value(vmconfig, 'config') uuid = sxp.child_value(vmconfig, 'uuid') - dominfo = XendDomainInfo.restore(config, uuid=uuid) - self._add_domain(dominfo) + dominfo = XendDomainInfo.restore(self.dbmap, config, uuid=uuid) return dominfo def domain_restore(self, src, progress=False): @@ -330,8 +339,12 @@ try: info = self.xen_domain(id) if info: - log.info("Creating entry for unknown domain: id=%d", id) - dominfo = XendDomainInfo.recreate(None, info) + uuid = getUuid() + log.info( + "Creating entry for unknown domain: id=%d uuid=%s", + id, uuid) + db = self.dbmap.addChild(uuid) + dominfo = XendDomainInfo.recreate(db, info) self._add_domain(dominfo) except Exception, ex: log.exception("Error creating domain info: id=%d", id) @@ -593,7 +606,7 @@ """ dominfo = self.domain_lookup(id) val = dominfo.device_create(devconfig) - self.sync_domain(dominfo) + dominfo.exportToDB() return val def domain_device_configure(self, id, devconfig, devid): @@ -606,7 +619,7 @@ """ dominfo = self.domain_lookup(id) val = dominfo.device_configure(devconfig, devid) - self.sync_domain(dominfo) + dominfo.exportToDB() return val def domain_device_refresh(self, id, type, devid): @@ -618,7 +631,7 @@ """ dominfo = self.domain_lookup(id) val = dominfo.device_refresh(type, devid) - self.sync_domain(dominfo) + dominfo.exportToDB() return val def domain_device_destroy(self, id, type, devid): @@ -630,7 +643,7 @@ """ dominfo = self.domain_lookup(id) val = dominfo.device_destroy(type, devid) - self.sync_domain(dominfo) + dominfo.exportToDB() return val def domain_devtype_ls(self, id, type): diff -Nru a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py --- a/tools/python/xen/xend/XendDomainInfo.py 2005-06-09 13:10:14 -04:00 +++ b/tools/python/xen/xend/XendDomainInfo.py 2005-06-09 13:10:14 -04:00 @@ -30,6 +30,7 @@ from xen.xend.XendRoot import get_component from xen.xend.uuid import getUuid +from xen.xend.xenstore import DBVar """Flag for a block device backend domain.""" SIF_BLK_BE_DOMAIN = (1<<4) @@ -145,94 +146,92 @@ """ MINIMUM_RESTART_TIME = 20 - def _create(cls, uuid=None): - """Create a vm object with a uuid. - - @param uuid uuid to use - @return vm - """ - if uuid is None: - uuid = getUuid() - vm = cls() - vm.uuid = uuid - return vm - - _create = classmethod(_create) - - def create(cls, config): + def create(cls, parentdb, config): """Create a VM from a configuration. - If a vm has been partially created and there is an error it - is destroyed. + @param parentdb: parent db @param config configuration @raise: VmError for invalid configuration """ - vm = cls._create() + uuid = getUuid() _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |