}
-int
-qemuMonitorAddHostNetwork(qemuMonitorPtr mon,
- const char *netstr,
- int *tapfd, char **tapfdName, int tapfdSize,
- int *vhostfd, char **vhostfdName, int vhostfdSize)
-{
- int ret = -1;
- size_t i = 0, j = 0;
-
- VIR_DEBUG("netstr=%s tapfd=%p tapfdName=%p tapfdSize=%d "
- "vhostfd=%p vhostfdName=%p vhostfdSize=%d",
- netstr, tapfd, tapfdName, tapfdSize,
- vhostfd, vhostfdName, vhostfdSize);
-
- QEMU_CHECK_MONITOR(mon);
-
- for (i = 0; i < tapfdSize; i++) {
- if (qemuMonitorSendFileHandle(mon, tapfdName[i], tapfd[i]) < 0)
- goto cleanup;
- }
- for (j = 0; j < vhostfdSize; j++) {
- if (qemuMonitorSendFileHandle(mon, vhostfdName[j], vhostfd[j]) < 0)
- goto cleanup;
- }
-
- if (mon->json)
- virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
- _("JSON monitor should be using AddNetdev"));
- else
- ret = qemuMonitorTextAddHostNetwork(mon, netstr);
-
- cleanup:
- if (ret < 0) {
- while (i--) {
- if (qemuMonitorCloseFileHandle(mon, tapfdName[i]) < 0)
- VIR_WARN("failed to close device handle '%s'", tapfdName[i]);
- }
- while (j--) {
- if (qemuMonitorCloseFileHandle(mon, vhostfdName[j]) < 0)
- VIR_WARN("failed to close device handle '%s'", vhostfdName[j]);
- }
- }
-
- return ret;
-}
-
-
-int
-qemuMonitorRemoveHostNetwork(qemuMonitorPtr mon,
- int vlan,
- const char *netname)
-{
- VIR_DEBUG("netname=%s", netname);
-
- QEMU_CHECK_MONITOR(mon);
-
- if (mon->json) {
- virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
- _("JSON monitor should be using RemoveNetdev"));
- return -1;
- }
-
- return qemuMonitorTextRemoveHostNetwork(mon, vlan, netname);
-}
-
-
int
qemuMonitorAddNetdev(qemuMonitorPtr mon,
const char *netdevstr,
const char *fdname);
int qemuMonitorRemoveFd(qemuMonitorPtr mon, int fdset, int fd);
-/* XXX do we really want to hardcode 'netstr' as the
- * sendable item here
- */
-int qemuMonitorAddHostNetwork(qemuMonitorPtr mon,
- const char *netstr,
- int *tapfd, char **tapfdName, int tapfdSize,
- int *vhostfd, char **vhostfdName, int vhostfdSize);
-
-int qemuMonitorRemoveHostNetwork(qemuMonitorPtr mon,
- int vlan,
- const char *netname);
-
int qemuMonitorAddNetdev(qemuMonitorPtr mon,
const char *netdevstr,
int *tapfd, char **tapfdName, int tapfdSize,
}
-int qemuMonitorTextAddHostNetwork(qemuMonitorPtr mon,
- const char *netstr)
-{
- char *cmd;
- char *reply = NULL;
- int ret = -1;
-
- if (virAsprintf(&cmd, "host_net_add %s", netstr) < 0)
- return -1;
-
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
- goto cleanup;
-
- if (STRNEQ(reply, "")) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("unable to add host net: %s"),
- reply);
- goto cleanup;
- }
-
- ret = 0;
-
- cleanup:
- VIR_FREE(cmd);
- VIR_FREE(reply);
- return ret;
-}
-
-
-int qemuMonitorTextRemoveHostNetwork(qemuMonitorPtr mon,
- int vlan,
- const char *netname)
-{
- char *cmd;
- char *reply = NULL;
- int ret = -1;
-
- if (virAsprintf(&cmd, "host_net_remove %d %s", vlan, netname) < 0)
- return -1;
-
- if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
- goto cleanup;
-
- /* XXX error messages here ? */
-
- ret = 0;
-
- cleanup:
- VIR_FREE(cmd);
- VIR_FREE(reply);
- return ret;
-}
-
-
int qemuMonitorTextAddNetdev(qemuMonitorPtr mon,
const char *netdevstr)
{