Program: 105888
Project: 105888
Buggy source:
/** 
 * This is a tricky to create network in xenserver. if you create a network then create bridge by brctl or openvswitch yourself, then you will get an expection that is "REQUIRED_NETWROK" when you start a vm with this network. The soultion is, create a vif of dom0 and plug it in network, xenserver will create the bridge on behalf of you
 * @throws XmlRpcException
 * @throws XenAPIException
 */
private void enableXenServerNetwork(Connection conn,Network nw,String vifNameLabel,String networkDesc) throws XenAPIException, XmlRpcException {
  VIF dom0vif=null;
  Pair<VM,VM.Record> vm=getControlDomain(conn);
  VM dom0=vm.first();
  Set<VIF> dom0Vifs=dom0.getVIFs(conn);
  for (  VIF vif : dom0Vifs) {
    vif.getRecord(conn);
    if (vif.getNetwork(conn).getUuid(conn) == nw.getUuid(conn)) {
      dom0vif=vif;
      s_logger.debug("String_Node_Str");
    }
  }
  if (dom0vif == null) {
    s_logger.debug("String_Node_Str" + networkDesc);
    VIF.Record vifr=new VIF.Record();
    vifr.VM=dom0;
    vifr.device=getLowestAvailableVIFDeviceNum(conn,dom0);
    if (vifr.device == null) {
      s_logger.debug("String_Node_Str" + networkDesc + "String_Node_Str");
      return;
    }
    Map<String,String> config=new HashMap<String,String>();
    config.put("String_Node_Str",vifNameLabel);
    vifr.otherConfig=config;
    vifr.MAC="String_Node_Str";
    vifr.network=nw;
    vifr.lockingMode=Types.VifLockingMode.NETWORK_DEFAULT;
    dom0vif=VIF.create(conn,vifr);
  }
  dom0vif.plug(conn);
  dom0vif.unplug(conn);
synchronized (_tmpDom0Vif) {
    _tmpDom0Vif.add(dom0vif);
  }
}

Fixed version (ground truth):
/** 
 * This is a tricky to create network in xenserver. if you create a network then create bridge by brctl or openvswitch yourself, then you will get an expection that is "REQUIRED_NETWROK" when you start a vm with this network. The soultion is, create a vif of dom0 and plug it in network, xenserver will create the bridge on behalf of you
 * @throws XmlRpcException
 * @throws XenAPIException
 */
private void enableXenServerNetwork(Connection conn,Network nw,String vifNameLabel,String networkDesc) throws XenAPIException, XmlRpcException {
  VIF dom0vif=null;
  Pair<VM,VM.Record> vm=getControlDomain(conn);
  VM dom0=vm.first();
  Set<VIF> dom0Vifs=dom0.getVIFs(conn);
  for (  VIF vif : dom0Vifs) {
    vif.getRecord(conn);
    if (vif.getNetwork(conn).getUuid(conn).equals(nw.getUuid(conn))) {
      dom0vif=vif;
      s_logger.debug("String_Node_Str");
    }
  }
  if (dom0vif == null) {
    s_logger.debug("String_Node_Str" + networkDesc);
    VIF.Record vifr=new VIF.Record();
    vifr.VM=dom0;
    vifr.device=getLowestAvailableVIFDeviceNum(conn,dom0);
    if (vifr.device == null) {
      s_logger.debug("String_Node_Str" + networkDesc + "String_Node_Str");
      return;
    }
    Map<String,String> config=new HashMap<String,String>();
    config.put("String_Node_Str",vifNameLabel);
    vifr.otherConfig=config;
    vifr.MAC="String_Node_Str";
    vifr.network=nw;
    vifr.lockingMode=Types.VifLockingMode.NETWORK_DEFAULT;
    dom0vif=VIF.create(conn,vifr);
  }
  dom0vif.plug(conn);
  dom0vif.unplug(conn);
synchronized (_tmpDom0Vif) {
    _tmpDom0Vif.add(dom0vif);
  }
}