// NOTE(Crazykev): This method may be changed when support multiple container per Pod.
// CreateContainer creates VM which contains container defined in container spec
This method may be changed when support multiple container per Pod.
CreateContainer creates VM which contains container defined in container spec
// NOTE ( Crazykev ) : This method may be changed when support multiple container per Pod . // CreateContainer creates VM which contains container defined in container spec
func (vt *VMTool) CreateContainer(ctrMeta *metadata.ContainerMetadata, sbMeta *metadata.SandboxMetadata) error {
	settings := VMSetting{
		domainName: sbMeta.Name,
		domainUUID: sbMeta.ID,
		vcpuNum:    int(sbMeta.VMConfig.CPUNum),
		memory:     int(sbMeta.VMConfig.Memory),
		image:      ctrMeta.ImageRef,
		enableKVM:  enableKVM(),
		logPath:    filepath.Join(sbMeta.LogDir, ctrMeta.LogPath),
	}
	if err := os.MkdirAll(filepath.Dir(settings.logPath), 0644); err != nil {
		return fmt.Errorf("failed create log directory %q", settings.logPath)
	}
	domainxml, err := vt.createDomain(&settings)
	if err != nil {
		return fmt.Errorf("failed to create domain with config(%v): %v", settings, err)
	}
	vt.appendSerialDevices(domainxml, &settings)
	if _, err = vt.conn.DefineDomain(domainxml); err != nil {
		return err
	}
	domain, err := vt.conn.GetDomainByUUIDString(settings.domainUUID)
	if err != nil {
		if domain != nil {
			if err1 := domain.Undefine(); err1 != nil {
				glog.Errorf("Failed to undefine failed domain: %v", err1)
			}
		}
		return err
	}
	return nil
}
func ( vt * VMTool ) CreateContainer ( ctrMeta * metadata . ContainerMetadata , sbMeta * metadata . SandboxMetadata ) error { settings := VMSetting { domainName : sbMeta . Name , domainUUID : sbMeta . ID , vcpuNum : int ( sbMeta . VMConfig . CPUNum ) , memory : int ( sbMeta . VMConfig . Memory ) , image : ctrMeta . ImageRef , enableKVM : enableKVM ( ) , logPath : filepath . Join ( sbMeta . LogDir , ctrMeta . LogPath ) , } if err := os . MkdirAll ( filepath . Dir ( settings . logPath ) , 0644 ) ; err != nil { return fmt . Errorf ( " " , settings . logPath ) } domainxml , err := vt . createDomain ( & settings ) if err != nil { return fmt . Errorf ( " " , settings , err ) } vt . appendSerialDevices ( domainxml , & settings ) if _ , err = vt . conn . DefineDomain ( domainxml ) ; err != nil { return err } domain , err := vt . conn . GetDomainByUUIDString ( settings . domainUUID ) if err != nil { if domain != nil { if err1 := domain . Undefine ( ) ; err1 != nil { glog . Errorf ( " " , err1 ) } } return err } return nil }
This method may be changed when support multiple container per Pod.
This method may be changed when support multiple container per Pod .
// Make sure log directory exist // FIXME(Crazykev): Is kubelet's responsibility to clean up the log directory? // Append serial devices to domain