OLD | NEW |
1 """ | 1 """ |
2 Interfaces to the QEMU monitor. | 2 Interfaces to the QEMU monitor. |
3 | 3 |
4 @copyright: 2008-2010 Red Hat Inc. | 4 @copyright: 2008-2010 Red Hat Inc. |
5 """ | 5 """ |
6 | 6 |
7 import socket, time, threading, logging, select | 7 import socket, time, threading, logging, select |
8 import kvm_utils | 8 import virt_utils |
9 try: | 9 try: |
10 import json | 10 import json |
11 except ImportError: | 11 except ImportError: |
12 logging.warning("Could not import json module. " | 12 logging.warning("Could not import json module. " |
13 "QMP monitor functionality disabled.") | 13 "QMP monitor functionality disabled.") |
14 | 14 |
15 | 15 |
16 class MonitorError(Exception): | 16 class MonitorError(Exception): |
17 pass | 17 pass |
18 | 18 |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 logging.debug("(monitor %s) Sending command '%s'", | 546 logging.debug("(monitor %s) Sending command '%s'", |
547 self.name, cmd) | 547 self.name, cmd) |
548 if not self._acquire_lock(20): | 548 if not self._acquire_lock(20): |
549 raise MonitorLockError("Could not acquire exclusive lock to send " | 549 raise MonitorLockError("Could not acquire exclusive lock to send " |
550 "QMP command '%s'" % cmd) | 550 "QMP command '%s'" % cmd) |
551 | 551 |
552 try: | 552 try: |
553 # Read any data that might be available | 553 # Read any data that might be available |
554 self._read_objects() | 554 self._read_objects() |
555 # Send command | 555 # Send command |
556 id = kvm_utils.generate_random_string(8) | 556 id = virt_utils.generate_random_string(8) |
557 self._send(json.dumps(self._build_cmd(cmd, args, id)) + "\n") | 557 self._send(json.dumps(self._build_cmd(cmd, args, id)) + "\n") |
558 # Read response | 558 # Read response |
559 r = self._get_response(id, timeout) | 559 r = self._get_response(id, timeout) |
560 if r is None: | 560 if r is None: |
561 raise MonitorProtocolError("Received no response to QMP " | 561 raise MonitorProtocolError("Received no response to QMP " |
562 "command '%s', or received a " | 562 "command '%s', or received a " |
563 "response with an incorrect id" | 563 "response with an incorrect id" |
564 % cmd) | 564 % cmd) |
565 if "return" in r: | 565 if "return" in r: |
566 if debug and r["return"]: | 566 if debug and r["return"]: |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 | 754 |
755 def migrate_set_speed(self, value): | 755 def migrate_set_speed(self, value): |
756 """ | 756 """ |
757 Set maximum speed (in bytes/sec) for migrations. | 757 Set maximum speed (in bytes/sec) for migrations. |
758 | 758 |
759 @param value: Speed in bytes/sec | 759 @param value: Speed in bytes/sec |
760 @return: The response to the command | 760 @return: The response to the command |
761 """ | 761 """ |
762 args = {"value": value} | 762 args = {"value": value} |
763 return self.cmd("migrate_set_speed", args) | 763 return self.cmd("migrate_set_speed", args) |
OLD | NEW |