qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 1/3] backup: QEMU Backup Tool


From: Fam Zheng
Subject: Re: [Qemu-devel] [PATCH v2 1/3] backup: QEMU Backup Tool
Date: Wed, 30 Aug 2017 12:15:39 +0800
User-agent: Mutt/1.8.3 (2017-05-23)

On Tue, 08/29 22:13, Ishani Chugh wrote:
> +    def _restore(self, guest_name):
> +        """
> +        Prints Steps to perform restore operation
> +        """
> +        if guest_name not in self.config.sections():
> +            print("Cannot find specified guest", file=sys.stderr)
> +            sys.exit(1)
> +
> +        self.verify_guest_running(guest_name)
> +        connection = QEMUMonitorProtocol(
> +                                         self.get_socket_address(
> +                                             self.config[guest_name]['qmp']))
> +        connection.connect()
> +        print("To perform restore:")
> +        print("Shut down guest")
> +        for key in self.config[guest_name]:
> +            if key.startswith("drive_"):
> +                drive = key[len('drive_'):]
> +                target = self.config[guest_name][key]
> +                cmd = {'execute': 'query-block'}
> +                returned_json = connection.cmd_obj(cmd)
> +                device_present = False
> +                for device in returned_json['return']:
> +                    if device['device'] == drive:
> +                        device_present = True
> +                        location = device['inserted']['image']['filename']
> +                        print("Replace " + location + " By " + target)

Maybe just

    print("qemu-img convert " + location + " " + target)

which is almost ready to copy&paste into a command line? (You or the user needs
take care of quoting and escaping to handle the special characters, if any.)

> +
> +                if not device_present:
> +                    print("No such drive in guest", file=sys.stderr)
> +                    sys.exit(1)
> +

Fam



reply via email to

[Prev in Thread] Current Thread [Next in Thread]