function network_change_xml($network, $xml)
 {
     $net = $this->get_network_res($network);
     if (!($old_xml = libvirt_network_get_xml_desc($net, NULL))) {
         return $this->_set_last_error();
     }
     if (!libvirt_network_undefine($net)) {
         return $this->_set_last_error();
     }
     if (!libvirt_network_define_xml($this->conn, $xml)) {
         $this->last_error = libvirt_get_last_error();
         libvirt_network_define_xml($this->conn, $old_xml);
         return false;
     }
     return true;
 }
Пример #2
0
/**
 * create and activate a virtual network
 *
 * @global  resource $host_conn       libvirt connection
 *
 * @param   string   $host_name       name of virt host (only so we can pass to VIRSH)
 * @param   string   $network_virt_id virt_id of network
 *
 * @return  bool                on success TRUE/FALSE
 */
function ace_kvm_network_create($host_name, $network_virt_id)
{
    global $host_conn;
    $xml = '<network><name>' . $network_virt_id . '</name><bridge name="' . $network_virt_id . '" /></network>';
    if ($network_res = libvirt_network_define_xml($host_conn, $xml)) {
        ace_kvm_log_last_error();
        //$success = ace_kvm_set_network_state($network_virt_id, true);
        $success = ace_kvm_network_activate_virsh($host_name, $network_virt_id);
        $return = $success;
    } else {
        $return = FALSE;
    }
    return $return;
}