Android-cuttlefish cvd tool
qcow2.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#pragma once
17
18#include <stdint.h>
19
20#include <memory>
21#include <string>
22#include <string_view>
23
27
28namespace cuttlefish {
29
37class Qcow2Image : public DiskImage {
38 public:
47 const std::string& crosvm_path, std::string_view backing_file,
48 std::string_view output_overlay_path);
50 const DiskImage& backing_image, std::string_view backing_file,
51 std::string_view output_overlay_path);
52 static Result<Qcow2Image> CreateByCrosvm(const std::string& crosvm_path,
53 const std::string& backing_file,
54 std::string output_overlay_path);
55 static Result<Qcow2Image> CreateByQemuImg(const DiskImage& backing_image,
56 const std::string& backing_file,
57 std::string output_overlay_path);
58 static Result<Qcow2Image> OpenExisting(std::string path);
59
61 ~Qcow2Image() override;
63
70 static std::string MagicString();
71
72 Result<uint64_t> VirtualSizeBytes() const override;
73 Result<std::string> QemuImgName() const override;
74
75 private:
76 struct Impl;
77
78 Qcow2Image(std::unique_ptr<Impl>);
79
80 std::unique_ptr<Impl> impl_;
81};
82
83} // namespace cuttlefish
Definition: disk_image.h:26
Definition: qcow2.h:37
static Result< Qcow2Image > CreateByQemuImg(const DiskImage &backing_image, const std::string &backing_file, std::string output_overlay_path)
Definition: qcow2.cc:99
static std::string MagicString()
Definition: qcow2.cc:122
Qcow2Image(Qcow2Image &&)
Definition: qcow2.cc:124
Qcow2Image & operator=(Qcow2Image &&)
Definition: qcow2.cc:126
std::unique_ptr< Impl > impl_
Definition: qcow2.h:80
Result< std::string > QemuImgName() const override
Definition: qcow2.cc:137
static Result< Qcow2Image > OpenExisting(std::string path)
Definition: qcow2.cc:108
static Result< Command > CreateByQemuImgCommand(const DiskImage &backing_image, std::string_view backing_file, std::string_view output_overlay_path)
Definition: qcow2.cc:74
static Result< Command > CreateByCrosvmCommand(const std::string &crosvm_path, std::string_view backing_file, std::string_view output_overlay_path)
Definition: qcow2.cc:63
Result< uint64_t > VirtualSizeBytes() const override
Definition: qcow2.cc:131
static Result< Qcow2Image > CreateByCrosvm(const std::string &crosvm_path, const std::string &backing_file, std::string output_overlay_path)
Definition: qcow2.cc:90
Definition: alloc_driver.h:21
tl::expected< T, StackTraceError< E > > Result
Definition: result_type.h:30
Definition: qcow2.cc:59