// virtioBlkStorageHandler handles the storage for blk driver.
325074
func virtioBlkStorageHandler(storage pb.Storage, s *sandbox) (string, error) {
	// Get the device node path based on the PCI address provided
	// in Storage Source
	devPath, err := getPCIDeviceName(s, storage.Source)
	if err != nil {
		return "", err
	}
	storage.Source = devPath

	return commonStorageHandler(storage)
}
1155512
func UpdateObjectStorage(s storer.Storer, packfile io.Reader) error {
	if pw, ok := s.(storer.PackfileWriter); ok {
		return WritePackfileToObjectStorage(pw, packfile)
	}

	p, err := NewParserWithStorage(NewScanner(packfile), s)
	if err != nil {
		return err
	}

	_, err = p.Parse()
	return err
}
1299947
func NewStorageBackend(st *State) (*storageBackend, error) {
	// TODO(wallyworld) - we should be passing in a Model not a State
	// (but need to move stuff off State first)
	m, err := st.Model()
	if err != nil {
		return nil, errors.Trace(err)
	}
	registry, err := st.storageProviderRegistry()
	if err != nil {
		return nil, errors.Annotate(err, "getting storage provider registry")
	}

	return &storageBackend{
		mb:              st,
		registry:        registry,
		settings:        NewStateSettings(st),
		modelType:       m.Type(),
		config:          m.ModelConfig,
		application:     st.Application,
		allApplications: st.AllApplications,
		unit:            st.Unit,
		machine:         st.Machine,
	}, nil
}
459233
func ParseRethinkDBStorage(configuration *viper.Viper) (*RethinkDBStorage, error) {
	store := RethinkDBStorage{
		Storage: Storage{
			Backend: configuration.GetString("storage.backend"),
			Source:  configuration.GetString("storage.db_url"),
		},
		CA:       GetPathRelativeToConfig(configuration, "storage.tls_ca_file"),
		Cert:     GetPathRelativeToConfig(configuration, "storage.client_cert_file"),
		Key:      GetPathRelativeToConfig(configuration, "storage.client_key_file"),
		DBName:   configuration.GetString("storage.database"),
		Username: configuration.GetString("storage.username"),
		Password: configuration.GetString("storage.password"),
	}

	switch {
	case store.Backend != notary.RethinkDBBackend:
		return nil, fmt.Errorf(
			"%s is not a supported RethinkDB backend driver",
			store.Backend,
		)
	case store.Source == "":
		return nil, fmt.Errorf(
			"must provide a non-empty host:port for %s",
			store.Backend,
		)
	case store.CA == "":
		return nil, fmt.Errorf(
			"cowardly refusal to connect to %s without a CA cert",
			store.Backend,
		)
	case store.Cert == "" || store.Key == "":
		return nil, fmt.Errorf(
			"cowardly refusal to connect to %s without a client cert and key",
			store.Backend,
		)
	case store.DBName == "":
		return nil, fmt.Errorf(
			"%s requires a specific database to connect to",
			store.Backend,
		)
	case store.Username == "":
		return nil, fmt.Errorf(
			"%s requires a username to connect to the db",
			store.Backend,
		)
	}

	return &store, nil
}
934171
func (env *environ) StorageProvider(t storage.ProviderType) (storage.Provider, error) {
	if env.storageSupported() && t == lxdStorageProviderType {
		return &lxdStorageProvider{env}, nil
	}
	return nil, errors.NotFoundf("storage provider %q", t)
}
1243840
func (s *Service) IntermediateStorage(c context.Context, rw bool) (storage.Storage, error) {
	cfg := s.ServiceConfig()
	if cfg.GetStorage() == nil {
		log.Errorf(c, "Missing storage configuration.")
		return nil, ErrInvalidConfig
	}

	btcfg := cfg.GetStorage().GetBigtable()
	if btcfg == nil {
		log.Errorf(c, "Missing BigTable storage configuration")
		return nil, ErrInvalidConfig
	}

	// Determine our scopes.
	scopes := bigtable.StorageReadOnlyScopes
	if rw {
		scopes = bigtable.StorageScopes
	}

	// Initialize RPC credentials.
	ts, err := serverAuth.GetTokenSource(c, serverAuth.AsSelf, serverAuth.WithScopes(scopes...))
	if err != nil {
		return nil, err
	}
	client, err := cloudBT.NewClient(c, btcfg.Project, btcfg.Instance,
		option.WithUserAgent(s.getUserAgent()), option.WithTokenSource(ts))
	if err != nil {
		return nil, err
	}
	return &bigtable.Storage{
		Client:   client,
		LogTable: btcfg.LogTableName,
	}, nil
}
1172529
func WithStorageBackend(ctx context.Context, sb StorageBackend) context.Context {
	return context.WithValue(ctx, ctxKeyStorageBackend, sb)
}
402437
func (p *StoragePool) NumOfStorageVolumes() (int, error) {
	var err C.virError
	result := int(C.virStoragePoolNumOfVolumesWrapper(p.ptr, &err))
	if result == -1 {
		return 0, makeError(&err)
	}
	return result, nil
}
747746
func (m *VcenterVStorageObjectManager) statDatastoreBacking(ctx *Context, ref types.ManagedObjectReference, id *types.ID) map[types.ID]error {
	objs := m.objects[ref] // default to checking all objects
	if id != nil {
		// check for a specific object
		objs = map[types.ID]*VStorageObject{
			*id: objs[*id],
		}
	}
	res := make(map[types.ID]error, len(objs))
	ds := ctx.Map.Get(ref).(*Datastore)
	dc := ctx.Map.getEntityDatacenter(ds)
	fm := ctx.Map.FileManager()

	for _, obj := range objs {
		backing := obj.Config.Backing.(*types.BaseConfigInfoDiskFileBackingInfo)
		file, _ := fm.resolve(&dc.Self, backing.FilePath)
		_, res[obj.Config.Id] = os.Stat(file)
	}

	return res
}
1354566
func StorageBackends() []string {
	bes := make([]string, 0, len(storageNameToBackendMap))
	for k := range storageNameToBackendMap {
		bes = append(bes, k)
	}
	sort.Strings(bes)
	return bes
}
1177987
func (e *azureStorageProvider) Supports(k storage.StorageKind) bool {
	return k == storage.StorageKindBlock
}
987761
func (a *azureObjects) StorageInfo(ctx context.Context) (si minio.StorageInfo) {
	return si
}
593987
func (c *Connect) GetStoragePoolCapabilities(flags uint32) (string, error) {
	if C.LIBVIR_VERSION_NUMBER < 5002000 {
		return "", makeNotImplementedError("virConnectGetStoragePoolCapabilities")
	}

	var err C.virError
	ret := C.virConnectGetStoragePoolCapabilitiesWrapper(c.ptr, C.uint(flags), &err)
	if ret == nil {
		return "", makeError(&err)
	}

	defer C.free(unsafe.Pointer(ret))

	return C.GoString(ret), nil
}
497709
func (c *Client) ListBlobStorages(i *ListBlobStoragesInput) ([]*BlobStorage, error) {
	if i.Service == "" {
		return nil, ErrMissingService
	}

	if i.Version == 0 {
		return nil, ErrMissingVersion
	}

	path := fmt.Sprintf("/service/%s/version/%d/logging/azureblob", i.Service, i.Version)
	resp, err := c.Get(path, nil)
	if err != nil {
		return nil, err
	}

	var as []*BlobStorage
	if err := decodeJSON(&as, resp.Body); err != nil {
		return nil, err
	}
	sort.Stable(blobStorageByName(as))
	return as, nil
}
697635
func virtio9pStorageHandler(storage pb.Storage, s *sandbox) (string, error) {
	return commonStorageHandler(storage)
}
1181684
func (p *StoragePool) StorageVolCreateXML(xmlConfig string, flags StorageVolCreateFlags) (*StorageVol, error) {
	cXml := C.CString(string(xmlConfig))
	defer C.free(unsafe.Pointer(cXml))
	var err C.virError
	ptr := C.virStorageVolCreateXMLWrapper(p.ptr, cXml, C.uint(flags), &err)
	if ptr == nil {
		return nil, makeError(&err)
	}
	return &StorageVol{ptr: ptr}, nil
}
83610
func (c *Connect) LookupStorageVolByPath(path string) (*StorageVol, error) {
	cPath := C.CString(path)
	defer C.free(unsafe.Pointer(cPath))
	var err C.virError
	ptr := C.virStorageVolLookupByPathWrapper(c.ptr, cPath, &err)
	if ptr == nil {
		return nil, makeError(&err)
	}
	return &StorageVol{ptr: ptr}, nil
}