Example #1
0
def stress_write():
    xstransact.Write(PATH, 'key', '1')
    while True:
        val = xstransact.Gather(PATH, ('key', int))
        xstransact.Store(PATH, ('key', val + 1))

        random_sleep()
Example #2
0
 def exportToDB(self, save=False, sync=False):
     to_store = {
         'id': self.id,
         'dbid': self.dbid,
         'config': sxp.to_string(self.config)
     }
     xstransact.Write(self.dbpath, to_store)
    def writeBackend(self, devid, *args):
        backpath = self.readVm(devid, "backend")

        if backpath:
            xstransact.Write(backpath, *args)
        else:
            raise VmError("Device %s not connected" % devid)
Example #4
0
 def change_xenstore(self, action, device, major, minor):
     for type in DEVICE_TYPES:
         path = self.dbpath + '/' + type
         domains = xstransact.List(path)
         log.debug('domains: %s', domains)
         for domain in domains:  # for each domain
             devices = xstransact.List(path + '/' + domain)
             log.debug('devices: %s', devices)
             for device in devices:  # for each vbd device
                 str = device.split('/')
                 vbd_type = None
                 vbd_physical_device = None
                 vbd_media = None
                 vbd_device_path = path + '/' + domain + '/' + device
                 listing = xstransact.List(vbd_device_path)
                 for entry in listing:  # for each entry
                     item = path + '/' + entry
                     value = xstransact.Read(vbd_device_path + '/' + entry)
                     log.debug('%s=%s', item, value)
                     if item.find('media-present') != -1:
                         vbd_media = item
                         vbd_media_path = item
                     if item.find('physical-device') != -1:
                         vbd_physical_device = value
                     if item.find('type') != -1:
                         vbd_type = value
                 if vbd_type is not None and vbd_physical_device is not None and vbd_media is not None:
                     inode = vbd_physical_device.split(':')
                     imajor = parse_hex(inode[0])
                     iminor = parse_hex(inode[1])
                     log.debug(
                         "action:%s major:%s- minor:%s- imajor:%s- iminor:%s- inode: %s",
                         action, major, minor, imajor, iminor, inode)
                     if int(imajor) == int(major) and int(iminor) == int(
                             minor):
                         if action == "add":
                             xs_dict = {'media': "1"}
                             xstransact.Write(vbd_device_path,
                                              'media-present', "1")
                             log.debug(
                                 "wrote xenstore media-present 1 path:%s",
                                 vbd_media_path)
                         else:
                             xstransact.Write(vbd_device_path,
                                              'media-present', "0")
                             log.debug("wrote xenstore media 0 path:%s",
                                       vbd_media_path)
Example #5
0
    def writeBackend(self, devid, *args):
        frontpath = self.frontendPath(devid)
        backpath = xstransact.Read(frontpath, "backend")

        if backpath:
            xstransact.Write(backpath, *args)
        else:
            raise VmError("Device %s not connected" % devid)
Example #6
0
 def update_XS(self, pool_id):
     """ Write (or update) data in xenstore taken from instance.
         @param pool_id: Pool id to build path to pool data in xenstore
         @type  pool_id: int
     """
     self.pool_lock.acquire()
     try:
         xs_path = XS_POOLROOT + "%s/" % pool_id
         xs_entries = {
             'uuid': self.get_uuid(),
             'name': self.name_label,
             'description': self.name_description
         }
         xstransact.Mkdir(xs_path)
         xstransact.Mkdir(xs_path, 'other_config')
         xstransact.Write(xs_path, xs_entries)
         xstransact.Write('%s%s' % (xs_path, 'other_config'),
                          self.other_config)
     finally:
         self.pool_lock.release()
Example #7
0
    def destroyDevice(self, devid):
        """Destroy the specified device.

        @param devid The device ID, or something device-specific from which
        the device ID can be determined (such as a guest-side device name).

        The implementation here simply deletes the appropriate paths from the
        store.  This may be overridden by subclasses who need to perform other
        tasks on destruction.  Further, the implementation here can only
        accept integer device IDs, or values that can be converted to
        integers.  Subclasses may accept other values and convert them to
        integers before passing them here.
        """

        devid = int(devid)
        
        frontpath = self.frontendPath(devid)
        backpath = xstransact.Read(frontpath, "backend")

        if backpath:
            xstransact.Write(backpath, 'state', str(xenbusState['Closing']))
        else:
            raise VmError("Device %s not connected" % devid)