2 * Copyright (C) 2013, 2014 Red Hat, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see
16 * <http://www.gnu.org/licenses/>.
22 #include "testutils.h"
23 #include "testutilsqemu.h"
24 #include "qemumonitortestutils.h"
25 #include "qemu/qemu_conf.h"
26 #include "qemu/qemu_agent.h"
27 #include "virthread.h"
29 #include "virstring.h"
32 #define VIR_FROM_THIS VIR_FROM_NONE
39 testQemuAgentFSFreeze(const void *data
)
41 virDomainXMLOptionPtr xmlopt
= (virDomainXMLOptionPtr
)data
;
42 qemuMonitorTestPtr test
= qemuMonitorTestNewAgent(xmlopt
);
43 const char *mountpoints
[] = {"/fs1", "/fs2", "/fs3", "/fs4", "/fs5"};
49 if (qemuMonitorTestAddAgentSyncResponse(test
) < 0)
52 if (qemuMonitorTestAddItem(test
, "guest-fsfreeze-freeze-list",
53 "{ \"return\" : 5 }") < 0)
56 if (qemuMonitorTestAddAgentSyncResponse(test
) < 0)
59 if (qemuMonitorTestAddItem(test
, "guest-fsfreeze-freeze",
60 "{ \"return\" : 7 }") < 0)
63 if ((ret
= qemuAgentFSFreeze(qemuMonitorTestGetAgent(test
),
68 virReportError(VIR_ERR_INTERNAL_ERROR
,
69 "expected 5 frozen filesystems, got %d", ret
);
73 if ((ret
= qemuAgentFSFreeze(qemuMonitorTestGetAgent(test
), NULL
, 0)) < 0)
77 virReportError(VIR_ERR_INTERNAL_ERROR
,
78 "expected 7 frozen filesystems, got %d", ret
);
85 qemuMonitorTestFree(test
);
91 testQemuAgentFSThaw(const void *data
)
93 virDomainXMLOptionPtr xmlopt
= (virDomainXMLOptionPtr
)data
;
94 qemuMonitorTestPtr test
= qemuMonitorTestNewAgent(xmlopt
);
100 if (qemuMonitorTestAddAgentSyncResponse(test
) < 0)
103 if (qemuMonitorTestAddItem(test
, "guest-fsfreeze-thaw",
104 "{ \"return\" : 5 }") < 0)
107 if (qemuMonitorTestAddAgentSyncResponse(test
) < 0)
110 if (qemuMonitorTestAddItem(test
, "guest-fsfreeze-thaw",
111 "{ \"return\" : 7 }") < 0)
114 if ((ret
= qemuAgentFSThaw(qemuMonitorTestGetAgent(test
))) < 0)
118 virReportError(VIR_ERR_INTERNAL_ERROR
,
119 "expected 5 thawed filesystems, got %d", ret
);
123 if ((ret
= qemuAgentFSThaw(qemuMonitorTestGetAgent(test
))) < 0)
127 virReportError(VIR_ERR_INTERNAL_ERROR
,
128 "expected 7 thawed filesystems, got %d", ret
);
135 qemuMonitorTestFree(test
);
141 testQemuAgentFSTrim(const void *data
)
143 virDomainXMLOptionPtr xmlopt
= (virDomainXMLOptionPtr
)data
;
144 qemuMonitorTestPtr test
= qemuMonitorTestNewAgent(xmlopt
);
150 if (qemuMonitorTestAddAgentSyncResponse(test
) < 0)
153 if (qemuMonitorTestAddItemParams(test
, "guest-fstrim",
154 "{ \"return\" : {} }",
159 if (qemuAgentFSTrim(qemuMonitorTestGetAgent(test
), 1337) < 0)
165 qemuMonitorTestFree(test
);
171 testQemuAgentGetFSInfo(const void *data
)
173 virDomainXMLOptionPtr xmlopt
= (virDomainXMLOptionPtr
)data
;
174 qemuMonitorTestPtr test
= qemuMonitorTestNewAgent(xmlopt
);
175 char *domain_filename
= NULL
;
176 virDomainDefPtr def
= NULL
;
177 virDomainFSInfoPtr
*info
= NULL
;
178 int ret
= -1, ninfo
= 0, i
;
183 if (virAsprintf(&domain_filename
, "%s/qemuagentdata/fsinfo.xml",
187 if (!(def
= virDomainDefParseFile(domain_filename
, driver
.caps
, xmlopt
,
188 NULL
, VIR_DOMAIN_DEF_PARSE_INACTIVE
)))
191 if (qemuMonitorTestAddAgentSyncResponse(test
) < 0)
194 if (qemuMonitorTestAddItem(test
, "guest-get-fsinfo",
196 " {\"name\": \"sda1\", \"mountpoint\": \"/\","
198 " {\"bus-type\": \"ide\","
199 " \"bus\": 1, \"unit\": 0,"
200 " \"pci-controller\": {"
201 " \"bus\": 0, \"slot\": 1,"
202 " \"domain\": 0, \"function\": 1},"
204 " \"type\": \"ext4\"},"
205 " {\"name\": \"dm-1\","
206 " \"mountpoint\": \"/opt\","
208 " {\"bus-type\": \"virtio\","
209 " \"bus\": 0, \"unit\": 0,"
210 " \"pci-controller\": {"
211 " \"bus\": 0, \"slot\": 6,"
212 " \"domain\": 0, \"function\": 0},"
214 " {\"bus-type\": \"virtio\","
215 " \"bus\": 0, \"unit\": 0,"
216 " \"pci-controller\": {"
217 " \"bus\": 0, \"slot\": 7,"
218 " \"domain\": 0, \"function\": 0},"
220 " \"type\": \"vfat\"},"
221 " {\"name\": \"sdb1\","
222 " \"mountpoint\": \"/mnt/disk\","
223 " \"disk\": [], \"type\": \"xfs\"}]}") < 0)
226 if ((ninfo
= qemuAgentGetFSInfo(qemuMonitorTestGetAgent(test
),
231 virReportError(VIR_ERR_INTERNAL_ERROR
,
232 "expected 3 filesystems information, got %d", ninfo
);
236 if (STRNEQ(info
[2]->name
, "sda1") ||
237 STRNEQ(info
[2]->mountpoint
, "/") ||
238 STRNEQ(info
[2]->fstype
, "ext4") ||
239 info
[2]->ndevAlias
!= 1 ||
240 !info
[2]->devAlias
|| !info
[2]->devAlias
[0] ||
241 STRNEQ(info
[2]->devAlias
[0], "hdc")) {
242 virReportError(VIR_ERR_INTERNAL_ERROR
,
243 "unexpected filesystems information returned for sda1 (%s,%s)",
244 info
[2]->name
, info
[2]->devAlias
? info
[2]->devAlias
[0] : "null");
248 if (STRNEQ(info
[1]->name
, "dm-1") ||
249 STRNEQ(info
[1]->mountpoint
, "/opt") ||
250 STRNEQ(info
[1]->fstype
, "vfat") ||
251 info
[1]->ndevAlias
!= 2 ||
252 !info
[1]->devAlias
|| !info
[1]->devAlias
[0] || !info
[1]->devAlias
[1] ||
253 STRNEQ(info
[1]->devAlias
[0], "vda") ||
254 STRNEQ(info
[1]->devAlias
[1], "vdb")) {
255 virReportError(VIR_ERR_INTERNAL_ERROR
,
256 "unexpected filesystems information returned for dm-1 (%s,%s)",
257 info
[0]->name
, info
[0]->devAlias
? info
[0]->devAlias
[0] : "null");
261 if (STRNEQ(info
[0]->name
, "sdb1") ||
262 STRNEQ(info
[0]->mountpoint
, "/mnt/disk") ||
263 STRNEQ(info
[0]->fstype
, "xfs") ||
264 info
[0]->ndevAlias
!= 0 || info
[0]->devAlias
) {
265 virReportError(VIR_ERR_INTERNAL_ERROR
,
266 "unexpected filesystems information returned for sdb1 (%s,%s)",
267 info
[0]->name
, info
[0]->devAlias
? info
[0]->devAlias
[0] : "null");
272 if (qemuMonitorTestAddAgentSyncResponse(test
) < 0)
275 if (qemuMonitorTestAddItem(test
, "guest-get-fsinfo",
277 " {\"class\":\"CommandDisabled\","
278 " \"desc\":\"The command guest-get-fsinfo "
279 "has been disabled for "
281 " \"data\":{\"name\":\"guest-get-fsinfo\"}"
286 if (qemuAgentGetFSInfo(qemuMonitorTestGetAgent(test
), &info
, def
) != -1) {
287 virReportError(VIR_ERR_INTERNAL_ERROR
, "%s",
288 "agent get-fsinfo command should have failed");
295 for (i
= 0; i
< ninfo
; i
++)
296 virDomainFSInfoFree(info
[i
]);
298 VIR_FREE(domain_filename
);
299 virDomainDefFree(def
);
300 qemuMonitorTestFree(test
);
306 testQemuAgentSuspend(const void *data
)
308 virDomainXMLOptionPtr xmlopt
= (virDomainXMLOptionPtr
)data
;
309 qemuMonitorTestPtr test
= qemuMonitorTestNewAgent(xmlopt
);
316 if (qemuMonitorTestAddAgentSyncResponse(test
) < 0)
319 if (qemuMonitorTestAddItem(test
, "guest-suspend-ram",
320 "{ \"return\" : {} }") < 0)
323 if (qemuMonitorTestAddAgentSyncResponse(test
) < 0)
326 if (qemuMonitorTestAddItem(test
, "guest-suspend-disk",
327 "{ \"return\" : {} }") < 0)
330 if (qemuMonitorTestAddAgentSyncResponse(test
) < 0)
333 if (qemuMonitorTestAddItem(test
, "guest-suspend-hybrid",
334 "{ \"return\" : {} }") < 0)
337 /* try the commands - fail if ordering changes */
338 for (i
= 0; i
< VIR_NODE_SUSPEND_TARGET_LAST
; i
++) {
339 if (qemuAgentSuspend(qemuMonitorTestGetAgent(test
), i
) < 0)
346 qemuMonitorTestFree(test
);
351 struct qemuAgentShutdownTestData
{
353 qemuAgentEvent event
;
358 qemuAgentShutdownTestMonitorHandler(qemuMonitorTestPtr test
,
359 qemuMonitorTestItemPtr item
,
362 struct qemuAgentShutdownTestData
*data
;
363 virJSONValuePtr val
= NULL
;
364 virJSONValuePtr args
;
369 data
= qemuMonitorTestItemGetPrivateData(item
);
371 if (!(val
= virJSONValueFromString(cmdstr
)))
374 if (!(cmdname
= virJSONValueObjectGetString(val
, "execute"))) {
375 ret
= qemuMonitorReportError(test
, "Missing command name in %s", cmdstr
);
379 if (STRNEQ(cmdname
, "guest-shutdown")) {
380 ret
= qemuMonitorTestAddInvalidCommandResponse(test
, "guest-shutdown",
385 if (!(args
= virJSONValueObjectGet(val
, "arguments"))) {
386 ret
= qemuMonitorReportError(test
,
387 "Missing arguments section");
391 if (!(mode
= virJSONValueObjectGetString(args
, "mode"))) {
392 ret
= qemuMonitorReportError(test
, "Missing shutdown mode");
396 if (STRNEQ(mode
, data
->mode
)) {
397 ret
= qemuMonitorReportError(test
,
398 "expected shutdown mode '%s' got '%s'",
403 /* now don't reply but return a qemu agent event */
404 qemuAgentNotifyEvent(qemuMonitorTestGetAgent(test
),
410 virJSONValueFree(val
);
417 testQemuAgentShutdown(const void *data
)
419 virDomainXMLOptionPtr xmlopt
= (virDomainXMLOptionPtr
)data
;
420 qemuMonitorTestPtr test
= qemuMonitorTestNewAgent(xmlopt
);
421 struct qemuAgentShutdownTestData priv
;
427 if (qemuMonitorTestAddAgentSyncResponse(test
) < 0)
430 priv
.event
= QEMU_AGENT_EVENT_SHUTDOWN
;
433 if (qemuMonitorTestAddHandler(test
, qemuAgentShutdownTestMonitorHandler
,
437 if (qemuAgentShutdown(qemuMonitorTestGetAgent(test
),
438 QEMU_AGENT_SHUTDOWN_HALT
) < 0)
441 if (qemuMonitorTestAddAgentSyncResponse(test
) < 0)
444 priv
.event
= QEMU_AGENT_EVENT_SHUTDOWN
;
445 priv
.mode
= "powerdown";
447 if (qemuMonitorTestAddHandler(test
, qemuAgentShutdownTestMonitorHandler
,
451 if (qemuAgentShutdown(qemuMonitorTestGetAgent(test
),
452 QEMU_AGENT_SHUTDOWN_POWERDOWN
) < 0)
455 if (qemuMonitorTestAddAgentSyncResponse(test
) < 0)
458 priv
.event
= QEMU_AGENT_EVENT_RESET
;
459 priv
.mode
= "reboot";
461 if (qemuMonitorTestAddHandler(test
, qemuAgentShutdownTestMonitorHandler
,
465 if (qemuAgentShutdown(qemuMonitorTestGetAgent(test
),
466 QEMU_AGENT_SHUTDOWN_REBOOT
) < 0)
469 /* check negative response, so that we can verify that the agent breaks
472 if (qemuMonitorTestAddAgentSyncResponse(test
) < 0)
475 if (qemuMonitorTestAddItem(test
, "guest-shutdown",
477 " {\"class\":\"CommandDisabled\","
478 " \"desc\":\"The command guest-shutdown has "
479 "been disabled for this instance\","
480 " \"data\":{\"name\":\"guest-shutdown\"}"
485 if (qemuAgentShutdown(qemuMonitorTestGetAgent(test
),
486 QEMU_AGENT_SHUTDOWN_REBOOT
) != -1) {
487 virReportError(VIR_ERR_INTERNAL_ERROR
, "%s",
488 "agent shutdown command should have failed");
495 qemuMonitorTestFree(test
);
500 static const char testQemuAgentCPUResponse
[] =
503 " {\"online\": true,"
504 " \"can-offline\": false,"
507 " {\"online\": true,"
508 " \"can-offline\": true,"
511 " {\"online\": true,"
512 " \"can-offline\": true,"
515 " {\"online\": false,"
516 " \"can-offline\": true,"
522 static const char testQemuAgentCPUArguments1
[] =
523 "[{\"logical-id\":1,\"online\":false}]";
525 static const char testQemuAgentCPUArguments2
[] =
526 "[{\"logical-id\":1,\"online\":true},"
527 "{\"logical-id\":3,\"online\":true}]";
529 static const char testQemuAgentCPUArguments3
[] =
530 "[{\"logical-id\":3,\"online\":true}]";
533 testQemuAgentCPU(const void *data
)
535 virDomainXMLOptionPtr xmlopt
= (virDomainXMLOptionPtr
)data
;
536 qemuMonitorTestPtr test
= qemuMonitorTestNewAgent(xmlopt
);
537 qemuAgentCPUInfoPtr cpuinfo
= NULL
;
544 if (qemuMonitorTestAddAgentSyncResponse(test
) < 0)
547 if (qemuMonitorTestAddItem(test
, "guest-get-vcpus",
548 testQemuAgentCPUResponse
) < 0)
552 if ((nvcpus
= qemuAgentGetVCPUs(qemuMonitorTestGetAgent(test
),
557 virReportError(VIR_ERR_INTERNAL_ERROR
,
558 "Expected '4' cpus, got '%d'", nvcpus
);
562 /* try to unplug one */
563 if (qemuAgentUpdateCPUInfo(2, cpuinfo
, nvcpus
) < 0)
566 if (qemuMonitorTestAddAgentSyncResponse(test
) < 0)
569 if (qemuMonitorTestAddItemParams(test
, "guest-set-vcpus",
570 "{ \"return\" : 1 }",
571 "vcpus", testQemuAgentCPUArguments1
,
575 if (qemuAgentSetVCPUs(qemuMonitorTestGetAgent(test
), cpuinfo
, nvcpus
) < 0)
578 /* try to hotplug two, second one will fail*/
579 if (qemuMonitorTestAddAgentSyncResponse(test
) < 0)
582 if (qemuMonitorTestAddItemParams(test
, "guest-set-vcpus",
583 "{ \"return\" : 1 }",
584 "vcpus", testQemuAgentCPUArguments2
,
588 if (qemuMonitorTestAddAgentSyncResponse(test
) < 0)
591 if (qemuMonitorTestAddItemParams(test
, "guest-set-vcpus",
592 "{ \"error\" : \"random error\" }",
593 "vcpus", testQemuAgentCPUArguments3
,
597 if (qemuAgentUpdateCPUInfo(4, cpuinfo
, nvcpus
) < 0)
600 /* this should fail */
601 if (qemuAgentSetVCPUs(qemuMonitorTestGetAgent(test
), cpuinfo
, nvcpus
) != -1)
608 qemuMonitorTestFree(test
);
613 static const char testQemuAgentArbitraryCommandResponse
[] =
614 "{\"return\":\"bla\"}";
617 testQemuAgentArbitraryCommand(const void *data
)
619 virDomainXMLOptionPtr xmlopt
= (virDomainXMLOptionPtr
)data
;
620 qemuMonitorTestPtr test
= qemuMonitorTestNewAgent(xmlopt
);
627 if (qemuMonitorTestAddAgentSyncResponse(test
) < 0)
630 if (qemuMonitorTestAddItem(test
, "ble",
631 testQemuAgentArbitraryCommandResponse
) < 0)
634 if (qemuAgentArbitraryCommand(qemuMonitorTestGetAgent(test
),
635 "{\"execute\":\"ble\"}",
637 VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK
) < 0)
640 if (STRNEQ(reply
, testQemuAgentArbitraryCommandResponse
)) {
641 virReportError(VIR_ERR_INTERNAL_ERROR
,
642 "invalid processing of guest agent reply: "
643 "got '%s' expected '%s'",
644 reply
, testQemuAgentArbitraryCommandResponse
);
652 qemuMonitorTestFree(test
);
658 qemuAgentTimeoutTestMonitorHandler(qemuMonitorTestPtr test ATTRIBUTE_UNUSED
,
659 qemuMonitorTestItemPtr item ATTRIBUTE_UNUSED
,
660 const char *cmdstr ATTRIBUTE_UNUSED
)
667 testQemuAgentTimeout(const void *data
)
669 virDomainXMLOptionPtr xmlopt
= (virDomainXMLOptionPtr
)data
;
670 qemuMonitorTestPtr test
= qemuMonitorTestNewAgent(xmlopt
);
677 if (virTestGetExpensive() == 0) {
682 if (qemuMonitorTestAddHandler(test
, qemuAgentTimeoutTestMonitorHandler
,
686 if (qemuAgentFSFreeze(qemuMonitorTestGetAgent(test
), NULL
, 0) != -1) {
687 virReportError(VIR_ERR_INTERNAL_ERROR
, "%s",
688 "agent command should have failed");
693 if (qemuMonitorTestAddAgentSyncResponse(test
) < 0)
696 if (qemuMonitorTestAddHandler(test
, qemuAgentTimeoutTestMonitorHandler
,
700 if (qemuAgentArbitraryCommand(qemuMonitorTestGetAgent(test
),
701 "{\"execute\":\"ble\"}",
704 virReportError(VIR_ERR_INTERNAL_ERROR
, "%s",
705 "agent command didn't time out");
713 qemuMonitorTestFree(test
);
717 static const char testQemuAgentGetInterfacesResponse
[] =
720 " {\"name\":\"eth2\","
721 " \"hardware-address\":\"52:54:00:36:2a:e5\""
723 " {\"name\":\"eth1:0\","
726 " {\"ip-address-type\":\"ipv4\","
727 " \"ip-address\":\"192.168.10.91\","
730 " {\"ip-address-type\":\"ipv6\","
731 " \"ip-address\":\"fe80::fc54:ff:fefe:4c4f\","
735 " \"hardware-address\":\"52:54:00:d3:39:ee\""
737 " {\"name\":\"eth0\","
740 " {\"ip-address-type\":\"ipv6\","
741 " \"ip-address\":\"fe80::5054:ff:fe89:ad35\","
744 " {\"ip-address-type\":\"ipv4\","
745 " \"ip-address\":\"192.168.102.142\","
748 " {\"ip-address-type\":\"ipv4\","
749 " \"ip-address\":\"192.168.234.152\","
752 " {\"ip-address-type\":\"ipv6\","
753 " \"ip-address\":\"fe80::5054:ff:fec3:68bb\","
757 " \"hardware-address\":\"52:54:00:89:ad:35\""
759 " {\"name\":\"eth1\","
762 " {\"ip-address-type\":\"ipv4\","
763 " \"ip-address\":\"192.168.103.83\","
766 " {\"ip-address-type\":\"ipv6\","
767 " \"ip-address\":\"fe80::5054:ff:fed3:39ee\","
771 " \"hardware-address\":\"52:54:00:d3:39:ee\""
776 " {\"ip-address-type\":\"ipv4\","
777 " \"ip-address\":\"127.0.0.1\","
780 " {\"ip-address-type\":\"ipv6\","
781 " \"ip-address\":\"::1\","
785 " \"hardware-address\":\"00:00:00:00:00:00\""
791 testQemuAgentGetInterfaces(const void *data
)
793 virDomainXMLOptionPtr xmlopt
= (virDomainXMLOptionPtr
)data
;
794 qemuMonitorTestPtr test
= qemuMonitorTestNewAgent(xmlopt
);
797 int ifaces_count
= 0;
798 virDomainInterfacePtr
*ifaces
= NULL
;
803 if (qemuMonitorTestAddAgentSyncResponse(test
) < 0)
806 if (qemuMonitorTestAddItem(test
, "guest-network-get-interfaces",
807 testQemuAgentGetInterfacesResponse
) < 0)
810 if ((ifaces_count
= qemuAgentGetInterfaces(qemuMonitorTestGetAgent(test
),
814 if (ifaces_count
!= 4) {
815 virReportError(VIR_ERR_INTERNAL_ERROR
,
816 "expected 4 interfaces, got %d", ret
);
820 if (STRNEQ(ifaces
[0]->name
, "eth2") ||
821 STRNEQ(ifaces
[1]->name
, "eth1") ||
822 STRNEQ(ifaces
[2]->name
, "eth0") ||
823 STRNEQ(ifaces
[3]->name
, "lo")) {
824 virReportError(VIR_ERR_INTERNAL_ERROR
, "%s",
825 "unexpected return values for interface names");
829 if (STRNEQ(ifaces
[0]->hwaddr
, "52:54:00:36:2a:e5") ||
830 STRNEQ(ifaces
[1]->hwaddr
, "52:54:00:d3:39:ee") ||
831 STRNEQ(ifaces
[2]->hwaddr
, "52:54:00:89:ad:35") ||
832 STRNEQ(ifaces
[3]->hwaddr
, "00:00:00:00:00:00")) {
833 virReportError(VIR_ERR_INTERNAL_ERROR
, "%s",
834 "unexpected return values for MAC addresses");
838 if (ifaces
[0]->naddrs
!= 0 ||
839 ifaces
[1]->naddrs
!= 4 ||
840 ifaces
[2]->naddrs
!= 4 ||
841 ifaces
[3]->naddrs
!= 2) {
842 virReportError(VIR_ERR_INTERNAL_ERROR
, "%s",
843 "unexpected return values for number of IP addresses");
847 if (ifaces
[1]->addrs
[0].type
!= VIR_IP_ADDR_TYPE_IPV4
||
848 ifaces
[1]->addrs
[1].type
!= VIR_IP_ADDR_TYPE_IPV6
||
849 ifaces
[1]->addrs
[2].type
!= VIR_IP_ADDR_TYPE_IPV4
||
850 ifaces
[1]->addrs
[3].type
!= VIR_IP_ADDR_TYPE_IPV6
||
851 ifaces
[2]->addrs
[0].type
!= VIR_IP_ADDR_TYPE_IPV6
||
852 ifaces
[2]->addrs
[1].type
!= VIR_IP_ADDR_TYPE_IPV4
||
853 ifaces
[2]->addrs
[2].type
!= VIR_IP_ADDR_TYPE_IPV4
||
854 ifaces
[2]->addrs
[3].type
!= VIR_IP_ADDR_TYPE_IPV6
||
855 ifaces
[3]->addrs
[0].type
!= VIR_IP_ADDR_TYPE_IPV4
||
856 ifaces
[3]->addrs
[1].type
!= VIR_IP_ADDR_TYPE_IPV6
) {
857 virReportError(VIR_ERR_INTERNAL_ERROR
, "%s",
858 "unexpected return values for IP address types");
862 if (ifaces
[1]->addrs
[0].prefix
!= 24 ||
863 ifaces
[1]->addrs
[1].prefix
!= 64 ||
864 ifaces
[1]->addrs
[2].prefix
!= 32 ||
865 ifaces
[1]->addrs
[3].prefix
!= 64 ||
866 ifaces
[2]->addrs
[0].prefix
!= 64 ||
867 ifaces
[2]->addrs
[1].prefix
!= 24 ||
868 ifaces
[2]->addrs
[2].prefix
!= 16 ||
869 ifaces
[2]->addrs
[3].prefix
!= 64 ||
870 ifaces
[3]->addrs
[0].prefix
!= 8 ||
871 ifaces
[3]->addrs
[1].prefix
!= 128) {
872 virReportError(VIR_ERR_INTERNAL_ERROR
, "%s",
873 "unexpected return values for IP address prefix");
877 if (STRNEQ(ifaces
[1]->addrs
[0].addr
, "192.168.10.91") ||
878 STRNEQ(ifaces
[1]->addrs
[1].addr
, "fe80::fc54:ff:fefe:4c4f") ||
879 STRNEQ(ifaces
[1]->addrs
[2].addr
, "192.168.103.83") ||
880 STRNEQ(ifaces
[1]->addrs
[3].addr
, "fe80::5054:ff:fed3:39ee") ||
881 STRNEQ(ifaces
[2]->addrs
[0].addr
, "fe80::5054:ff:fe89:ad35") ||
882 STRNEQ(ifaces
[2]->addrs
[1].addr
, "192.168.102.142") ||
883 STRNEQ(ifaces
[2]->addrs
[2].addr
, "192.168.234.152") ||
884 STRNEQ(ifaces
[2]->addrs
[3].addr
, "fe80::5054:ff:fec3:68bb") ||
885 STRNEQ(ifaces
[3]->addrs
[0].addr
, "127.0.0.1") ||
886 STRNEQ(ifaces
[3]->addrs
[1].addr
, "::1")) {
887 virReportError(VIR_ERR_INTERNAL_ERROR
, "%s",
888 "unexpected return values for IP address values");
895 qemuMonitorTestFree(test
);
897 for (i
= 0; i
< ifaces_count
; i
++)
898 virDomainInterfaceFree(ifaces
[i
]);
911 fputs("libvirt not compiled with JSON support, skipping this test\n", stderr
);
915 if (virThreadInitialize() < 0 ||
916 qemuTestDriverInit(&driver
) < 0)
919 virEventRegisterDefaultImpl();
921 #define DO_TEST(name) \
922 if (virTestRun(# name, testQemuAgent ## name, driver.xmlopt) < 0) \
932 DO_TEST(ArbitraryCommand
);
933 DO_TEST(GetInterfaces
);
935 DO_TEST(Timeout
); /* Timeout should always be called last */
937 qemuTestDriverFree(&driver
);
939 return (ret
== 0) ? EXIT_SUCCESS
: EXIT_FAILURE
;
942 VIR_TEST_MAIN(mymain
)