Ejemplo n.º 1
0
def start_qemu(qemu_exec,
               image,
               spice_port,
               qmp_filename,
               incoming_port=None,
               extra_args=[]):
    incoming_args = []
    if incoming_port:
        incoming_args = ("-incoming tcp::%s" % incoming_port).split()
    args = ([
        qemu_exec, "-qmp",
        "unix:%s,server,nowait" % qmp_filename, "-spice",
        "disable-ticketing,port=%s" % spice_port
    ] + incoming_args + extra_args)
    if os.path.exists(image):
        args += [
            "-m", "512", "-drive",
            "file=%s,index=0,media=disk,cache=unsafe" % image, "-snapshot"
        ]
    proc = Popen(args, executable=qemu_exec, stdin=PIPE, stdout=PIPE)
    while not os.path.exists(qmp_filename):
        time.sleep(0.1)
    proc.qmp_filename = qmp_filename
    proc.qmp = qmp.QEMUMonitorProtocol(qmp_filename)
    while True:
        try:
            proc.qmp.connect()
            break
        except socket.error, err:
            pass
Ejemplo n.º 2
0
def start_qemu(qemu_exec,
               seamless_migration,
               image,
               spice_port,
               qmp_filename,
               incoming_port=None,
               with_agent=False):
    seamless_option = "on" if seamless_migration else "off"
    args = [
        qemu_exec, "-qmp", f"unix:{qmp_filename},server,nowait", "-spice",
        f"seamless-migration={seamless_option},disable-ticketing,port={spice_port}"
    ]
    if incoming_port:
        args += (f"-incoming tcp::{incoming_port}").split()

    if with_agent:
        args += [
            '-device', 'virtio-serial', '-chardev',
            'spicevmc,name=vdagent,id=vdagent', '-device',
            'virtserialport,chardev=vdagent,name=com.redhat.spice.0'
        ]

    if os.path.exists(image):
        args += [
            "-m", "512", "-enable-kvm", "-drive",
            f"file={image},index=0,media=disk,cache=writeback"
        ]

    proc = Popen(args, executable=qemu_exec, stdin=PIPE, stdout=PIPE)

    while not os.path.exists(qmp_filename):
        time.sleep(0.1)
    proc.qmp_filename = qmp_filename
    proc.qmp = qmp.QEMUMonitorProtocol(qmp_filename)
    while True:
        try:
            proc.qmp.connect()
            break
        except socket.error:
            pass
    proc.spice_port = spice_port
    proc.incoming_port = incoming_port
    return proc
Ejemplo n.º 3
0
def start_qemu(qemu_exec, image, spice_port, qmp_filename, incoming_port=None, extra_args=[]):
    incoming_args = []
    if incoming_port:
        incoming_args = ("-incoming tcp::%s" % incoming_port).split()
    args = ([qemu_exec, "-qmp", "unix:%s,server,nowait" % qmp_filename,
        "-spice", "disable-ticketing,port=%s" % spice_port]
        + incoming_args + extra_args)
    if os.path.exists(image):
        args += ["-m", "512", "-drive",
                 "file=%s,index=0,media=disk,cache=unsafe" % image, "-snapshot"]
    proc = Popen(args, executable=qemu_exec, stdin=PIPE, stdout=PIPE)
    while not os.path.exists(qmp_filename):
        time.sleep(0.1)
    proc.qmp_filename = qmp_filename
    proc.qmp = qmp.QEMUMonitorProtocol(qmp_filename)
    while True:
        try:
            proc.qmp.connect()
            break
        except socket.error, err:
            pass