Skip to content

Commit

Permalink
Merge pull request lxc#502 from stgraber/empty
Browse files Browse the repository at this point in the history
Improvements to empty instance handling
  • Loading branch information
tych0 authored Feb 17, 2024
2 parents 9b5472c + 3f253a1 commit a77ce43
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
17 changes: 16 additions & 1 deletion internal/server/storage/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,22 @@ func (b *backend) CreateInstance(inst instance.Instance, op *operations.Operatio
return err
}

err = b.driver.CreateVolume(vol, nil, op)
var filler *drivers.VolumeFiller
if inst.Type() == instancetype.Container {
filler = &drivers.VolumeFiller{
Fill: func(vol drivers.Volume, rootBlockPath string, allowUnsafeResize bool) (int64, error) {
// Create an empty rootfs.
err := os.Mkdir(filepath.Join(vol.MountPath(), "rootfs"), 0755)
if err != nil && !os.IsExist(err) {
return 0, err
}

return 0, nil
},
}
}

err = b.driver.CreateVolume(vol, filler, op)
if err != nil {
return err
}
Expand Down
4 changes: 4 additions & 0 deletions internal/server/storage/quota/projectquota.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package quota
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <errno.h>
#ifndef FS_XFLAG_PROJINHERIT
struct fsxattr {
Expand Down Expand Up @@ -80,6 +81,9 @@ int quota_set(char *dev_path, uint32_t id, uint64_t hard_bytes) {
fs_disk_quota_t xfsquota;
if (quotactl(QCMD(Q_GETQUOTA, PRJQUOTA), dev_path, id, (caddr_t)&quota) < 0) {
if (hard_bytes == 0 && errno == ENOENT)
return 0;
return -1;
}
Expand Down

0 comments on commit a77ce43

Please sign in to comment.