def __init__(self, filename): fileformat = [] if filename.startswith("-f raw "): filename = filename[7:] fileformat = ['-f', 'raw'] self._filename = filename self._offset = 0 self._buf = None self._closed = True nbd_port = randint(10809, 20809) self._process = subprocess.Popen( ["qemu-nbd", "-b", "127.0.0.1", "-p", str(nbd_port)] + fileformat + [filename], shell=False, stdout=_devnull) # wait for qemu-nbd to start: this thing doesn't tell anything on stdout while True: try: self._client = nbd_client("127.0.0.1", nbd_port) break except: if self._process.poll() != None: raise Exception('Qemu terminated with exit code %d' % self._process.returncode) time.sleep(0.1) self._closed = False
def __init__(self, filename): self._filename = filename self._offset = 0 self._buf = None self._closed = True self._process = subprocess.Popen("qemu-nbd %s" % filename, shell=True, stdout=_devnull) # wait for qemu-nbd to start: this thing doesn't tell anything on stdout while True: try: self._client = nbd_client("localhost") break except: if self._process.poll() != None: raise Exception('Qemu terminated with exit code %d' % self._process.returncode) time.sleep(0.1) self._closed = False
def __init__(self, filename): self._filename = filename self._offset = 0 self._buf = None self._process = subprocess.Popen("qemu-nbd %s" % filename, shell = True, stdout=subprocess.PIPE) # wait for qemu-nbd to start: this thing doesn't tell anything on stdout while True: succeed = True try: self._client = nbd_client("localhost") except: time.sleep(0.1) succeed = False pass if succeed: break self._closed = False
def __init__(self, filename): fileformat = [] if filename.startswith("-f raw "): filename = filename[7:] fileformat = ['-f', 'raw'] self._filename = filename self._offset = 0 self._buf = None self._closed = True nbd_port = randint(10809, 20809) self._process = subprocess.Popen(["qemu-nbd", "-b", "127.0.0.1", "-p", str(nbd_port)] + fileformat + [filename], shell=False, stdout=_devnull) # wait for qemu-nbd to start: this thing doesn't tell anything on stdout while True: try: self._client = nbd_client("127.0.0.1", nbd_port) break except: if self._process.poll() != None: raise Exception('Qemu terminated with exit code %d' % self._process.returncode) time.sleep(0.1) self._closed = False